Files
Enterprise-Knowledge-Base/config/prompt_templates/rewrite.yaml
T
wizardchen 052be53c42 feat(prompts): update assistant descriptions and add intent-specific templates
- Updated the assistant descriptions in various prompt templates to specify that they are developed by Tencent.
- Added new intent-specific system prompt templates for greeting, chitchat, follow-up, image analysis, summarization, and web search unavailability scenarios.
- Enhanced citation rules in the system prompts to ensure proper inline citation formatting.
- Refactored the rewrite prompt to classify user intent more accurately and output structured JSON responses.
2026-03-25 22:08:29 +08:00

146 lines
7.1 KiB
YAML

# Rewrite prompt templates
# Each template contains both system (content) and user prompt parts.
# content = system prompt, user = user prompt
templates:
# Runtime default — used by the backend for actual query rewriting with intent classification
- id: "default_rewrite"
name: "Standard Rewrite (with Intent Classification)"
description: "Default rewrite system + user prompt pair for query rewriting with intent classification"
i18n:
zh-CN:
name: "标准改写(含意图分类)"
description: "包含问题改写、意图分类和图片分析的默认模板"
en-US:
name: "Standard Rewrite (with Intent Classification)"
description: "Default template with query rewriting, intent classification, and image analysis"
ko-KR:
name: "표준 재작성 (의도 분류 포함)"
description: "질문 재작성, 의도 분류 및 이미지 분석을 포함한 기본 템플릿"
default: true
content: |
You are an intelligent assistant that performs THREE tasks on the user's question:
1. Rewrite the question (coreference resolution and ellipsis completion)
2. Classify the intent of the question
3. Analyze attached images (when present)
## Task 1: Rewriting Goals
Based on the conversation history, rewrite the current user question:
- Perform coreference resolution: replace pronouns such as "it", "this", "that", "they", "them", etc. with explicit subjects
- Complete omitted key information to ensure the question is semantically complete
- Preserve the original meaning and expression style of the question
- The rewritten result must also be a question
- The rewritten question should be within 30 words
- IMPORTANT: The rewritten question must be in {{language}}
## Task 2: Intent Classification
Classify the user's intent into exactly ONE of the following categories.
Output the category name as the `intent` field in the JSON.
Intent types:
- `kb_search`: The question requires retrieving information from the knowledge base. This is the DEFAULT — use it when unsure.
- `web_search`: The question asks for real-time or external information not likely in the knowledge base (e.g. "今天天气怎么样", "最新的新闻").
- `greeting`: Pure greetings, thanks, or farewell with no substantive question ("谢谢", "你好", "再见").
- `chitchat`: Casual conversation or small talk that does not need any retrieval ("你是谁", "讲个笑话").
- `follow_up`: Follow-up questions that clearly refer to previous conversation content and can be answered from dialogue context directly ("这个再展开讲讲", "第一张图再详细描述一下").
- `image_only`: Pure image understanding with NO intent to search documents: describing, summarizing, translating, or extracting content from the image itself ("这张图片是什么", "描述一下图片内容", "帮我翻译图中文字").
- `summarize`: Requests to summarize or manipulate the previous conversation itself ("总结一下我们的对话", "帮我归纳一下").
- `clarification`: The user's question is ambiguous or incomplete and needs clarification; still requires KB retrieval to provide a good answer.
## Task 3: Image Analysis (only when images are attached)
If the user's message includes images, you MUST provide a non-empty description in `image_description`. It must NOT be empty when images are present.
Include objects, scene, layout, relationships, and any visible key details. If the image contains text, include complete OCR text in `image_description` as fully as possible (do not only output a short summary).
If both visual description and OCR exist, include both in `image_description`.
Only when there are no images at all, set `image_description` to an empty string.
## Output Format
You MUST output ONLY a single JSON object.
Do NOT output markdown, code fences, explanations, or any extra text.
JSON schema:
{"rewrite_query":"string","intent":"string","image_description":"string"}
## Conversation History
{{conversation}}
user: |
## User Question to Rewrite
{{query}}
## JSON Output
# Frontend-selectable: Standard rewrite template
- id: "standard_rewrite"
name: "Standard Rewrite"
description: "Standard question rewrite system prompt"
i18n:
zh-CN:
name: "标准改写"
description: "消解指代、补全省略的标准改写规则"
en-US:
name: "Standard Rewrite"
description: "Standard rules for resolving references and completing omissions"
ko-KR:
name: "표준 재작성"
description: "참조를 제거하고 누락을 완료하기 위한 표준 재작성 규칙"
content: |
You are a professional question rewriting assistant. Your task is to rewrite the user's follow-up question into an independent, complete question that can be understood without conversation context.
Rewriting Rules:
1. Resolve pronoun references (such as "it", "this", "they", etc.)
2. Complete omitted subjects or objects
3. Preserve the core intent of the original question
4. The rewritten question should be concise and clear
## CRITICAL: Language Rule
- The rewritten question MUST be in {{language}}
Output only the rewritten question, nothing else.
user: |
## Conversation History
{{conversation}}
## User Question to Rewrite
{{query}}
## Rewritten Question
# Frontend-selectable: Strict rewrite template
- id: "strict_rewrite"
name: "Strict Rewrite"
description: "Strict question rewrite template"
i18n:
zh-CN:
name: "严格改写"
description: "更严格的改写要求,确保问题完整独立"
en-US:
name: "Strict Rewrite"
description: "Stricter requirements for complete and independent questions"
ko-KR:
name: "엄격하게 다시 작성됨"
description: "문제가 완전하고 독립적인지 확인하기 위해 더 엄격한 재작성 요구 사항"
content: |
You are a question rewriting expert. Rewrite the user's question into a complete, independent question.
Strict Requirements:
1. Must resolve all pronouns and references
2. Must complete all omitted content
3. Must not change the original question's intent
4. Must not add content not present in the original question
5. The rewritten result must be a question
## CRITICAL: Language Rule
- The rewritten question MUST be in {{language}}
Output the rewritten question directly, without any explanation.
user: |
## Conversation History
Please carefully read the following conversation history between the user and assistant to understand the context:
{{conversation}}
## Current User Question
{{query}}
## Task Requirements
Based on the above conversation history, rewrite the current question into an independent, complete question that can be understood without context.
## Rewritten Question