From c8645843c37d598eb90beeb5e146c1780962c899 Mon Sep 17 00:00:00 2001 From: "jackson.jia" Date: Sat, 30 May 2026 10:47:41 +0800 Subject: [PATCH] fix(knowledge): wrap locale code with LanguageLocaleName in wiki ingest prompts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The wiki ingest pipeline was passing raw locale codes (e.g. "zh-CN", "en-US") directly into LLM prompts where a human-readable language name is expected. The model would see "zh-CN" instead of "Chinese (Simplified)" in its instructions, which could degrade output quality. Two call sites were affected: - SlugUpdate.Language (ProcessWikiIngest, retract path): consumed by the reduce phase to tell the page editor model what language to write in. - lang variable (mapOneDocument): consumed by entity/concept extraction, chunk citation classification, and index page rebuild — all LLM prompts. Wrap both with types.LanguageLocaleName() which maps locale codes to descriptive names (e.g. "zh-CN" → "Chinese (Simplified)"). Unknown locales fall through unchanged so no information is lost. --- internal/application/service/wiki_ingest_batch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/application/service/wiki_ingest_batch.go b/internal/application/service/wiki_ingest_batch.go index a12723e1..4f1530f8 100644 --- a/internal/application/service/wiki_ingest_batch.go +++ b/internal/application/service/wiki_ingest_batch.go @@ -425,7 +425,7 @@ func (s *wikiIngestService) ProcessWikiIngest(ctx context.Context, t *asynq.Task RetractDocContent: op.DocSummary, DocTitle: op.DocTitle, KnowledgeID: op.KnowledgeID, - Language: op.Language, + Language: types.LanguageLocaleName(op.Language), }) } mapMu.Unlock() @@ -770,7 +770,7 @@ func (s *wikiIngestService) mapOneDocument( ) (*docIngestResult, []SlugUpdate, error) { docStartedAt := time.Now() knowledgeID := op.KnowledgeID - lang := op.Language + lang := types.LanguageLocaleName(op.Language) // Open a postprocess.wiki subspan under the parent attempt's // postprocess stage so the actual per-doc work (LLM extraction +