Skip to content

Added glossaries as data source for fixed translations and term/context lookups - #1119

Open
0xnkr wants to merge 41 commits into
MindWorkAI:mainfrom
0xnkr:glossaries
Open

0xnkr wants to merge 41 commits into
MindWorkAI:mainfrom
0xnkr:glossaries

Conversation

@0xnkr

@0xnkr 0xnkr commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

PR

Summary

  • Added glossaries as a global data source that AI Studio stores itself, with two types:
    • Translation: terms with a fixed translation for one language pair
    • Reference: terms with an explanation, e.g., technical terms or invented words
  • Entries have a term, a value, optional other forms (e.g., plurals), and an optional note
  • New settings panel Configure Glossaries: inline-editable entry table with search, plus an import from spreadsheets and CSV/TSV files with column mapping, merge or replace, and language suggestions from the header row
  • Entries live in <data>/glossaries/<id>.json (part of backups); the settings hold only the description of each glossary. Unreadable files are never overwritten silently
  • Matching runs in .NET: normalized, case-insensitive substring search over terms and other forms, so compounds are found as well
  • Translation assistant: matches the chosen glossaries before each request and adds only the hits to the prompt (no tool call needed). Glossaries can be preselected; several can be chosen at once
  • New tool glossary_lookup lets the model look up glossary terms in chats; a raised minimum provider confidence carries over to the chat
  • Fixed the runtime's CSV export of spreadsheets: cells with commas, quotes, or line breaks are now quoted (affects every spreadsheet the app reads)
  • Glossaries from configuration plugins follow separately

Glossaries in configuration plugins

  • Configuration plugins can ship glossaries via CONFIG["GLOSSARIES"], with their entries either from a spreadsheet or CSV/TSV file inside the plugin folder (columns named by their header) or listed inline in Lua
    • Paths must be relative and stay inside the plugin folder
  • Organization glossaries are read-only for users
  • Glossaries can be exported as a configuration snippet including their entries and imported by others; DataApp.AllowUserToImportGlossary lets organizations lock this
  • The import preview and the delete confirmation of configuration plugins list their glossaries
  • Documented in the example plugin.lua and in Enterprise IT.md

Related proposal or issue

internal issue

How did you test it?

  • Built runtime and solution in Rider, ran dotnet test and cargo test
  • Ran the app locally: imported a German–English Excel glossary (including a cell with a comma), added, edited, and deleted glossaries, edited entries inline, checked the dialog layout in English and German, and checked the glossary selection and preselection in the translation assistant
  • Staged a test configuration under .config-tests with a file-based translation glossary (semicolon CSV), an inline reference glossary, and two broken definitions: checked the read-only view, preselection in the translation assistant, glossary_lookup in chat, hot reload after changing the file, removal of the plugin, the warnings for the broken definitions, the delete summary of a local configuration plugin, that a local plugin cannot override an organization glossary, snippet export and import, and the import lock

Required statements

  • Review: I have reviewed every change in this pull request and can explain it when asked.
  • License: I license my contribution in this pull request, including all commits I add to it later, under the MIT License, and I agree that it is distributed as part of MindWork AI Studio under the project license or under the MIT License.
  • Right to contribute: The contribution is my own work, or I have permission to submit it, including the consent of my employer or client where needed. To the best of my knowledge, it does not infringe the rights of others, and AI-generated parts do not reproduce third-party code under incompatible terms.
  • Changes by maintainers: I understand that the maintainers will change this pull request to fit the product, and that they may close it.

Credits (optional)

  • Credit me with my GitHub username only.
  • Do not credit me.

Wiki

For users

  • New settings panel Configure Glossaries: glossaries of two types, translation (term → fixed translation for one language pair) and reference (term → explanation). Entries are edited in a table or imported from a spreadsheet or CSV/TSV file.
  • Translation Assistant: choose one or more glossaries to use your given terms for a fixed translation . Only matching entries are sent to the AI.
  • New tool Glossary Lookup (glossary_lookup) for chats. Your given fixed translations or explanations are added to the prompt for extra context. Reference glossaries are useful when the AI should understand the terms of your field or your project: words which mean something specific to you but which the AI cannot know.

For IT departments

  • New configuration object CONFIG["GLOSSARIES"] with Id, Name, Type (TRANSLATION / REFERENCE), Description, SourceLanguage / TargetLanguage (+ CustomSourceLanguage / CustomTargetLanguage for OTHER), PreselectInTranslation (default true), and the entries either as
    • File = { Path, TermColumn, ValueColumn, optional OtherFormsColumn, NoteColumn }: a spreadsheet or CSV/TSV file inside the plugin folder (relative path, must stay inside it), columns named by their header, read whenever the plugin loads; or
    • Entries = list of { Term, Value, optional OtherForms, Note }.
  • Organization glossaries are read-only for users; their entries are kept in memory only, are not part of backups, and disappear with the plugin. Only the plugin that owns a glossary may provide its entries.
  • New setting DataApp.AllowUserToImportGlossary (default true) to allow or lock importing glossary snippets.
  • The tool glossary_lookup can be switched off or given a minimum provider confidence like any other tool (DataTools.DisabledToolIds, DataTools.MinimumProviderConfidenceByToolId, default NONE); a raised minimum carries over to the chat once entries reached it.
  • Import preview and delete confirmation of configuration plugins list their glossaries.

Pages concerned

  • Writing-Configuration-Plugins (new object GLOSSARIES)
  • Testing-and-Exporting-Configurations (export/import of glossaries, AllowUserToImportGlossary)
  • Tools-and-Web-Access (glossary_lookup)
  • Managing-Backups (glossaries/ folder)
  • User guide: settings and translation assistant (glossaries, preselection)

@0xnkr
0xnkr requested review from a team as code owners October 27, 2026 15:13
@0xnkr
0xnkr marked this pull request as draft October 27, 2026 15:13
@0xnkr 0xnkr mentioned this pull request Oct 27, 2026
5 of 6 tasks
@0xnkr 0xnkr self-assigned this Oct 27, 2026
0xnkr added 16 commits October 27, 2026 22:09
# Conflicts:
#	app/MindWork AI Studio/Assistants/I18N/allTexts.lua
#	app/MindWork AI Studio/Assistants/Translation/AssistantTranslation.razor.cs
#	app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua
#	app/MindWork AI Studio/Plugins/languages/en-us-97dfb1ba-50c4-4440-8dfa-6575daf543c8/plugin.lua
#	app/MindWork AI Studio/wwwroot/changelog/v26.10.1.md
#	documentation/Enterprise IT.md
The function of glossary_lookup goes along with every request of a chat,
whether the model looks anything up or not. Listing every glossary with
its ID, name, type, and description, plus every ID again as an enum,
grows with each glossary: about 30 to 110 tokens apiece, which fills the
context of a local model long before the chat starts and may run into
the limits some providers set for enums.

- Up to MAX_LISTED_GLOSSARIES (20), the function lists the glossaries
  and offers glossary_ids as before.
- Beyond that, it names only the language pairs of the translation
  glossaries and offers the optional filters source_language and
  target_language instead of glossary_ids. The lookup then searches all
  glossaries; the filters never leave out a reference glossary, and
  regional variants count as the same language, as in the translation
  assistant. The number of glossaries stays out of the description, so
  adding one does not break the prompt cache of the providers.
- The result now holds a section "glossaries" that describes every
  glossary with an entry on the page once: ID, name, type, and its
  description. With many glossaries, this is where the model learns
  which meaning of a term applies.
- The system prompt of the tool tells the model to use these
  descriptions when a term has entries in several glossaries.
- The glossary dialog and the example configuration plugin point out
  that the AI relies on the description to tell glossaries apart.
- Changelog entry for the compact mode.

Tests cover the switch at the limit, the language filters, and the new
section of the result.
GlossaryMatcher used to copy the whole text into a normalized string for
every search and then look for each term in it on its own: O(n * m) time
for a text of n characters and m terms, plus O(n) memory per glossary and
search. A long text in the translation assistant, up to about a million
tokens, met with many terms, made that slow and allocation-heavy.

The matcher now builds an Aho-Corasick automaton from the normalized
terms and aliases, once per list of entries, still cached in the
ConditionalWeakTable:

- The trie lives in flat arrays; the edges of a node are sorted by
  character and found by binary search. Failure and output links come
  from a breadth-first pass from the root.
- Entries sharing a normalized term share its end node, so duplicates,
  as in imported spreadsheets, are all found.
- FindEntries reads the text once as a ReadOnlySpan<char> and normalizes
  it on the fly exactly as Normalize does: lowercase, whitespace runs as
  a single space, none at the start or the end. The text is never copied.
- Collecting along the output links stops at the first term found
  before, and the search ends early once every term was found.

A search now takes O(n + m) time and O(m) extra memory; the automaton
takes O(L) memory for terms of total length L. The public API, the
matching rules, and the order of the results stay the same.

New tests check overlapping terms and terms ending other terms, entries
with the same term, and compare the automaton with the plain search on
1,000 random texts over a small alphabet. A further test searches 5,000
terms in 4 million characters and reports the time without asserting it.
- New help text for the description in the glossary dialog, which now
  explains that the AI tells glossaries apart by it.
- The en-US plugin catches up with the header of the glossary overview
  in the translation assistant, now split into one and several
  glossaries.
- German: the columns "Variants" and "Note" of the glossary overview
  now read "Andere Formen" and "Anmerkung", as in the glossary dialog.
# Conflicts:
#	app/MindWork AI Studio/Assistants/Translation/AssistantTranslation.razor
#	app/MindWork AI Studio/Assistants/Translation/AssistantTranslation.razor.cs
#	app/MindWork AI Studio/Plugins/configuration/plugin.lua
#	app/MindWork AI Studio/Settings/DataModel/Data.cs
#	app/MindWork AI Studio/Tools/PluginSystem/PluginConfigurationObjectTypeExtensions.cs
#	app/MindWork AI Studio/wwwroot/changelog/v26.11.1.md
@0xnkr
0xnkr marked this pull request as ready for review November 9, 2026 12:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant