Skip to content

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: strip thinking blocks before saving to wiki

nash_sud7587104acf9
diff --git a/src/components/chat/chat-message.tsx b/src/components/chat/chat-message.tsx
index 28d6df7f..41911ef1 100644
--- a/src/components/chat/chat-message.tsx
+++ b/src/components/chat/chat-message.tsx
@@ -139,8 +139,12 @@ function SaveToWikiButton({ content, visible }: { content: string; visible: bool
const fileName = `${slug}-${date}.md`
const filePath = `${pp}/wiki/queries/${fileName}`
- // Strip hidden sources comment from content
- const cleanContent = content.replace(/<!--\s*sources:.*?-->/g, "").trimEnd()
+ // Strip hidden sources comment and thinking blocks from content
+ const cleanContent = content
+ .replace(/<!--\s*sources:.*?-->/g, "")
+ .replace(/<think(?:ing)?>\s*[\s\S]*?<\/think(?:ing)?>\s*/gi, "")
+ .replace(/<think(?:ing)?>\s*[\s\S]*$/gi, "")
+ .trimEnd()
const frontmatter = [
"---",
diff --git a/src/lib/deep-research.ts b/src/lib/deep-research.ts
index 71b13519..237ceb9e 100644
--- a/src/lib/deep-research.ts
+++ b/src/lib/deep-research.ts
@@ -176,6 +176,12 @@ async function executeResearch(
.map((r, i) => `${i + 1}. [${r.title}](${r.url}) — ${r.source}`)
.join("\n")
+ // Strip <think>/<thinking> blocks before saving
+ const cleanedSynthesis = accumulated
+ .replace(/<think(?:ing)?>\s*[\s\S]*?<\/think(?:ing)?>\s*/gi, "")
+ .replace(/<think(?:ing)?>\s*[\s\S]*$/gi, "") // unclosed thinking block
+ .trimStart()
+
const pageContent = [
"---",
`type: query`,
@@ -187,7 +193,7 @@ async function executeResearch(
"",
`# Research: ${topic}`,
"",
- accumulated,
+ cleanedSynthesis,
"",
"## References",
"",