translate5 AI: Use the shared terminology context provider

XMLWordPrintable

    • Type: New Feature
    • Resolution: Unresolved
    • None
    • Affects Version/s: None
    • Component/s: translate5 AI

      Problem

      With the shared context-provider architecture in place, the existing AI terminology functionality must not remain a connector-specific parallel implementation. Today the OpenAI/translate5AI plugin fetches terminology inline in three separate call sites with two different gates:

      • Single/editor query: Connector::query() calls Connector::getTerms() (OpenAI/LanguageResource/Connector.php:308, 761-770), gated only on the TermTagger plugin being active (:143-145)
      • Batch pre-translation: the terms closure handed to the chunk policy (Connector.php:449 → Batch/ChunkPolicy.php:84,112), where terms also count toward the token budget of a chunk; the retry path reuses them via getTermsPerText() (Connector.php:591)
      • TQE: QualityEstimate/QualitySegmentFactory.php:64-96, additionally gated on runtimeOptions.plugins.OpenAI.qualityScoreUseTerminology

      All three end up in the same TermTagger TerminologyProvider, but each call site wires it separately - exactly the duplication the provider architecture is meant to remove.

      Solution

      Migrate the three call sites to the shared TerminologyContextProvider; the prompts and the resulting behaviour stay identical.

      • The OpenAI connector implements SupportsTerminologyContext; the injected TerminologyContext replaces Connector::getTerms():
        • single/editor path: terms for the segment are read from the injected context (injection happens in the generic _query())
        • batch path: the chunk-policy terms closure reads from the injected context instead of calling getTerms(); the token-budget behaviour and the retry path (getTermsPerText()) stay as they are (the batch injection runs in windows ahead of chunk building, so terms are available during tryAdd())
      • TQE path: QualitySegmentFactory receives a prepared TerminologyContext instead of owning a TerminologyProvider; the qualityScoreUseTerminology gate stays in the TQE flow and decides whether context is requested at all
      • The context DTOs (GlossaryTerm[]) are converted to the source => target map the completions expect; the prompt rendering (TranslateCompletion::buildTermsContent(), QualityScoreEstimateCompletion terms instruction) is not touched, so prompts remain byte-identical
      • Remove the now-duplicate wiring: Connector::getTerms(), the connector's own TerminologyProvider field, and the TerminologyProvider usage in QualitySegmentFactory - no term-search implementation remains in the AI plugin
      • The TermTagger-active gate lives in the shared provider (architecture ticket); the task terminologie flag behaviour is unchanged

            Assignee:
            Aleksandar Mitrev
            Reporter:
            Aleksandar Mitrev
            Aleksandar Mitrev Aleksandar Mitrev
            None
            Aleksandar Mitrev
            None
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              None
              None