chore(wiki): externalize compile prompts; doc archive tools + admin endpoints

This commit is contained in:
matevip 2026-04-25 19:02:33 +08:00
parent 58b49f6e20
commit 51566a47a4
3 changed files with 29 additions and 11 deletions

View File

@ -11,6 +11,7 @@ import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import vip.mate.agent.prompt.PromptLoader;
import vip.mate.wiki.job.WikiJobStep;
import vip.mate.wiki.job.WikiModelRoutingService;
import vip.mate.wiki.model.WikiChunkEntity;
@ -127,17 +128,12 @@ public class WikiCompileService {
throw new IllegalStateException("Refusing to compile over protected page: " + resolvedSlug);
}
// 3. Build LLM prompt.
String system = """
You are a wiki page compiler. Produce a single Markdown page that
synthesizes the supplied evidence. Constraints:
- Output ONLY a JSON object: {"title": "...", "summary": "...", "content": "..."}
- Do not invent facts beyond the evidence.
- Use [[wikilinks]] when an evidence breadcrumb names a related concept.
- Keep summary <= 300 characters.
- content must be Markdown with ## headers.
""";
String user = "## Topic\n\n" + topic + "\n\n## Evidence\n\n" + evidenceBlock;
// 3. Build LLM prompt prompt body lives in resources/prompts/wiki/compile-{system,user}.txt
// so we can iterate on phrasing without recompiling Java.
String system = PromptLoader.loadPrompt("wiki/compile-system");
String user = PromptLoader.loadPrompt("wiki/compile-user")
.replace("{topic}", topic)
.replace("{evidence}", evidenceBlock.toString());
ChatModel chatModel = resolveChatModel(kbId);
ChatResponse resp = chatModel.call(new Prompt(List.of(

View File

@ -0,0 +1,15 @@
You are a wiki page compiler. Produce a single Markdown page that synthesizes the supplied evidence chunks into a coherent article on the requested topic.
Strict output contract — return ONLY this JSON object, nothing else:
{
"title": "<page title>",
"summary": "<one paragraph, <= 300 characters>",
"content": "<Markdown body with ## headers>"
}
Rules:
- Do not invent facts beyond the supplied evidence. If something is not in the evidence, do not assert it.
- Use [[wikilinks]] when an evidence breadcrumb names a related concept; alias form [[slug|display]] is fine.
- Keep summary concise (single paragraph, <= 300 characters).
- content must be Markdown with at least one ## header.
- Do not include any prose outside the JSON object.

View File

@ -0,0 +1,7 @@
## Topic
{topic}
## Evidence
{evidence}