LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
fix: reinforce output language instruction to prevent Chinese bias
nash_sud88c7e1f63e9
diff --git a/src/components/chat/chat-panel.tsx b/src/components/chat/chat-panel.tsxindex 67eb125a..67d487b1 100644--- a/src/components/chat/chat-panel.tsx+++ b/src/components/chat/chat-panel.tsx@@ -283,14 +283,13 @@ export function ChatPanel() {`[${i + 1}] ${p.title} (${p.path})`).join("\n")+ const userLanguage = detectLanguage(text)+systemMessages.push({role: "system",content: ["You are a knowledgeable wiki assistant. Answer questions based on the wiki content provided below.","",- `## CRITICAL: Response Language`,- `The user is writing in **${detectLanguage(text)}**. You MUST respond in **${detectLanguage(text)}** regardless of what language the wiki content is written in. This is a mandatory requirement.`,- "","## Rules","- Answer based ONLY on the numbered wiki pages provided below.","- If the provided pages don't contain enough information, say so honestly.",@@ -305,9 +304,24 @@ export function ChatPanel() {index ? `## Wiki Index\n${index}` : "",relevantPages.length > 0 ? `## Page List\n${pageList}` : "",`## Wiki Pages\n\n${pagesContext}`,+ "",+ "---",+ "",+ `## ⚠️ MANDATORY OUTPUT LANGUAGE: ${userLanguage}`,+ "",+ `You MUST write your entire response in **${userLanguage}**.`,+ `The wiki content above may be in a different language, but this is IRRELEVANT to your output language.`,+ `Ignore the language of the wiki content. Write in ${userLanguage} only.`,+ `Even proper nouns should use standard ${userLanguage} transliteration when appropriate.`,+ `DO NOT use any other language. This overrides all other instructions.`,].filter(Boolean).join("\n"),})+ // Stash language reminder to inject right before the user's current message+ // (placed after history so it's the last system instruction LLM sees)+ const langReminder = `REMINDER: Respond in ${userLanguage}. The user's message is in ${userLanguage}; your response must also be in ${userLanguage}.`+ ;(systemMessages as unknown as { __langReminder?: string }).__langReminder = langReminder+lastQueryPages = relevantPages.map((p) => ({ title: p.title, path: p.path }))queryRefs = [...lastQueryPages]}@@ -318,7 +332,17 @@ export function ChatPanel() {.filter((m) => m.role === "user" || m.role === "assistant").slice(-maxHistoryMessages)- const llmMessages = [...systemMessages, ...chatMessagesToLLM(activeConvMessages)]+ // Inject language reminder as system message between history and final user query+ const langReminder = (systemMessages as unknown as { __langReminder?: string }).__langReminder+ const historyMessages = chatMessagesToLLM(activeConvMessages)+ const llmMessages = langReminder && historyMessages.length > 0+ ? [+ ...systemMessages,+ ...historyMessages.slice(0, -1),+ { role: "system" as const, content: langReminder },+ ...historyMessages.slice(-1),+ ]+ : [...systemMessages, ...historyMessages]const controller = new AbortController()abortRef.current = controller