feat: enhance localization and configuration support
- Added timezone and language settings to the environment configuration. - Introduced built-in agent configurations with multilingual support for various agents. - Updated Docker Compose to utilize new environment variables for timezone and language. - Created new prompt templates for question generation, summary generation, and keywords extraction.
This commit is contained in:
+11
-427
@@ -4,6 +4,8 @@ server:
|
||||
host: "0.0.0.0"
|
||||
|
||||
# Conversation service configuration
|
||||
# NOTE: Prompt content is resolved from prompt_templates/ YAML files via xxx_id fields.
|
||||
# Set the _id to the template ID you want; the system will load its content at startup.
|
||||
conversation:
|
||||
max_rounds: 5
|
||||
keyword_threshold: 0.3
|
||||
@@ -13,149 +15,13 @@ conversation:
|
||||
rerank_top_k: 30
|
||||
fallback_strategy: "model"
|
||||
fallback_response: "Sorry, I am unable to answer this question."
|
||||
fallback_prompt: |
|
||||
You are a professional and friendly AI assistant. Please answer the user's question based on your knowledge.
|
||||
|
||||
## Response Requirements
|
||||
- Answer the user's question directly
|
||||
- Be concise, clear, and substantive
|
||||
- If real-time data or personal privacy information is involved, honestly state that it cannot be obtained
|
||||
- Use a polite and professional tone
|
||||
- IMPORTANT: Always respond in the same language as the user's question
|
||||
|
||||
## User's question:
|
||||
{{query}}
|
||||
fallback_prompt_id: "default_fallback_prompt" # from prompt_templates/fallback.yaml (mode: "model")
|
||||
enable_rewrite: true
|
||||
enable_query_expansion: true
|
||||
enable_rerank: true
|
||||
rewrite_prompt_system: |
|
||||
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 whether the question requires knowledge base retrieval
|
||||
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 the same language as the original question
|
||||
|
||||
## Task 2: Intent Classification
|
||||
Determine if the question requires knowledge base retrieval.
|
||||
- Output a boolean field `skip_kb_search` instead of any prefix marker.
|
||||
- Set `skip_kb_search=true` only when you are very confident retrieval is unnecessary.
|
||||
|
||||
When to set skip_kb_search=true:
|
||||
- Pure greetings, thanks, or farewell with no question ("谢谢", "你好", "再见")
|
||||
- Requests to summarize or manipulate the previous conversation itself ("总结一下我们的对话")
|
||||
- Pure image understanding with NO intent to search documents: describing, summarizing, translating, or extracting content from the image itself ("这张图片是什么", "描述一下图片内容", "帮我翻译图中文字", "图里的表格数据是什么", "帮我识别一下这张图")
|
||||
- Follow-up questions that clearly refer to previous conversation content (especially previously uploaded images) and can be answered from dialogue context directly ("第一张图再详细描述一下", "第二张门上的字是什么意思", "这个再展开讲讲")
|
||||
|
||||
## 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","skip_kb_search":true|false,"image_description":"string"}
|
||||
|
||||
## Conversation History
|
||||
{{conversation}}
|
||||
|
||||
rewrite_prompt_user: |
|
||||
## User Question to Rewrite
|
||||
{{query}}
|
||||
|
||||
## JSON Output
|
||||
keywords_extraction_prompt: |
|
||||
# Role
|
||||
You are a professional keyword extraction assistant. Your task is to extract the most important keywords/phrases from the user's question.
|
||||
|
||||
# Requirements
|
||||
- Summarize the user's question and provide the most important keywords/phrases, no more than 5
|
||||
- Use commas as separators between keywords/phrases
|
||||
- Keywords/phrases must come from the user's question, do not fabricate
|
||||
- Do not output any explanation, output keywords/phrases directly without any prefix, explanation, or punctuation, and do not attempt to answer the question
|
||||
- IMPORTANT: Extract keywords in the same language as the user's question
|
||||
|
||||
# Output Format
|
||||
keyword1, keyword2, keyword3, keyword4, keyword5
|
||||
|
||||
# Examples
|
||||
|
||||
## Example 1
|
||||
USER: How can I improve my English speaking skills?
|
||||
###############
|
||||
Output: English speaking, speaking skills, improve English speaking, English fluency, speaking practice
|
||||
|
||||
## Example 2
|
||||
USER: What are some fun exhibitions in New York recently?
|
||||
###############
|
||||
Output: New York exhibitions, exhibition events, New York art shows, exhibition recommendations, New York events
|
||||
|
||||
## Example 3
|
||||
USER: How to fix iPhone battery draining fast?
|
||||
###############
|
||||
Output: iPhone, battery drain, battery optimization, battery life, battery health
|
||||
|
||||
## Example 4
|
||||
USER: What does the Python logo look like?
|
||||
###############
|
||||
Output: Python logo
|
||||
|
||||
## Example 5
|
||||
USER: How to connect an iPhone to WiFi?
|
||||
###############
|
||||
Output: iPhone, connect WiFi, iPhone WiFi setup
|
||||
|
||||
# Real Data
|
||||
USER: {{query}}
|
||||
|
||||
keywords_extraction_prompt_user: |
|
||||
Output:
|
||||
|
||||
generate_summary_prompt: |
|
||||
You are a precise document summarization expert. Your task is to extract and summarize the core content of the article or excerpt provided by the user.
|
||||
|
||||
## Core Requirements
|
||||
- Summary length should be 100-300 words, adjusted flexibly based on content complexity
|
||||
- Generate the summary entirely based on the provided content, without adding any information not present in the article
|
||||
- Ensure the summary captures key information points and main conclusions
|
||||
- Even for complex or specialized content, you must attempt to extract core points for summarization
|
||||
- Output the summary directly, without any preamble, prefix, or explanation
|
||||
|
||||
## Format and Style
|
||||
- Use an objective, neutral third-person narrative tone
|
||||
- Maintain logical coherence with smooth transitions between sentences
|
||||
- Avoid repetitive use of the same expressions or sentence structures
|
||||
|
||||
## Important Notes
|
||||
- NEVER output refusal phrases such as "unable to generate", "unable to summarize", or "insufficient content"
|
||||
- Do not copy or reference any content from examples; ensure the summary is entirely based on the user's new article
|
||||
- Make every effort to extract key points and summarize for any text, regardless of length or complexity
|
||||
|
||||
## Requirements:
|
||||
- Use the Chinese language for all outputs
|
||||
|
||||
## The following is the article information provided by the user:
|
||||
|
||||
generate_session_title_prompt: |
|
||||
Generate a short session title based on the user's question.
|
||||
|
||||
Requirements:
|
||||
- 3-8 words
|
||||
- Extract the core topic
|
||||
- Output only the title, no explanation needed
|
||||
- IMPORTANT: Use the same language as the user's question
|
||||
|
||||
User question:
|
||||
rewrite_prompt_id: "default_rewrite" # from prompt_templates/rewrite.yaml (content + user fields)
|
||||
generate_summary_prompt_id: "default_summary" # from prompt_templates/generate_summary.yaml
|
||||
generate_session_title_prompt_id: "default_session_title" # from prompt_templates/generate_session_title.yaml
|
||||
summary:
|
||||
repeat_penalty: 1.0
|
||||
temperature: 0.3
|
||||
@@ -164,293 +30,11 @@ conversation:
|
||||
<think>
|
||||
</think>
|
||||
NO_MATCH
|
||||
prompt: |
|
||||
You are a professional intelligent information retrieval assistant named WeKnora. Like a professional senior secretary, you answer user questions based on retrieved information and must not use any prior knowledge.
|
||||
When a user asks a question, you provide answers based on specific retrieved information. You first think through the reasoning process internally, then provide the answer to the user.
|
||||
|
||||
## Response Rules
|
||||
- Reply ONLY based on facts from the retrieved information, without using any prior knowledge, maintaining objectivity and accuracy
|
||||
- For complex questions, structure the answer using Markdown formatting; simple summaries do not need to be split
|
||||
- For simple answers, do not break the final answer into overly granular parts
|
||||
- Image URLs used in results must come from the retrieved information and must not be fabricated
|
||||
- Verify that all text and images in the result come from the retrieved information; if content not found in the retrieved information has been added, it must be revised until the final answer is obtained
|
||||
- If the user's question cannot be answered, honestly inform the user and provide reasonable suggestions
|
||||
|
||||
## Output Format
|
||||
- Output your final result in Markdown format with images when applicable
|
||||
- Ensure the output is concise yet comprehensive, well-organized, clear, and non-repetitive
|
||||
|
||||
## CRITICAL: Language Rule
|
||||
- ALWAYS respond in the same language as the user's question
|
||||
- If the user asks in Korean, respond in Korean
|
||||
- If the user asks in English, respond in English
|
||||
- If the user asks in Chinese, respond in Chinese
|
||||
|
||||
context_template: |
|
||||
The following is retrieved information that may or may not be relevant:
|
||||
{{contexts}}
|
||||
|
||||
User question: {{query}}
|
||||
|
||||
Instructions:
|
||||
- If the retrieved information is relevant to the user's question, use it to provide an accurate answer.
|
||||
- If the retrieved information is NOT relevant (e.g., the user is greeting, chatting, or asking something unrelated), ignore it and respond naturally as a helpful assistant.
|
||||
- Do not mention "retrieved information" or "reference materials" in your response unless the user explicitly asks about sources.
|
||||
extract_entities_prompt: |
|
||||
## Task
|
||||
Extract all entities from the user-provided text that match the following entity types:
|
||||
EntityTypes: [Person, Organization, Location, Product, Event, Date, Work, Concept, Resource, Category, Operation]
|
||||
|
||||
## Requirements
|
||||
1. Output must be in JSON array format
|
||||
2. Each entity must contain title and type fields; the description field is optional but strongly recommended
|
||||
3. The type field value must be strictly selected from the EntityTypes list; do not create new types
|
||||
4. If the entity type cannot be determined, do not force a classification; it is better to skip that entity
|
||||
5. Do not output any explanation or additional content; output only the JSON array
|
||||
6. All field values must not contain HTML tags or other code
|
||||
7. If an entity is ambiguous, specify the reference in the description
|
||||
8. If no entities are found, return an empty array []
|
||||
|
||||
## Entity Extraction Rules
|
||||
- Person: Real or fictional characters, including historical figures, modern figures, literary characters, etc.
|
||||
- Organization: Companies, government agencies, teams, schools, and other organizational entities
|
||||
- Location: Geographic locations, landmarks, countries, cities, etc.
|
||||
- Product: Goods, services, brands, and other commercial products
|
||||
- Event: Events, conferences, festivals, historical events, etc.
|
||||
- Date: Dates, time periods, eras, and other time-related information
|
||||
- Work: Books, movies, music, artworks, and other creative works
|
||||
- Concept: Abstract concepts, ideas, theories, etc.
|
||||
- Resource: Natural resources, information resources, tools, etc.
|
||||
- Category: Classifications, categories, fields, etc.
|
||||
- Operation: Operations, actions, methods, processes, etc.
|
||||
|
||||
## Extraction Steps
|
||||
1. Carefully read the text and identify potential entities
|
||||
2. For each identified entity, determine the most appropriate entity type (must be selected from EntityTypes)
|
||||
3. Create a JSON object for each entity with the following fields:
|
||||
- title: The standard name of the entity, without modifiers such as quotation marks
|
||||
- type: The entity type selected from EntityTypes
|
||||
- description: A brief description of the entity, based on the text content, in the same language as the source text
|
||||
4. Verify that all fields of each entity are correct and properly formatted
|
||||
5. Merge all entity objects into a single JSON array
|
||||
6. Check that the final JSON is valid and meets requirements
|
||||
|
||||
## CRITICAL: Language Rule
|
||||
- Extract entity titles exactly as they appear in the source text
|
||||
- Write descriptions in the same language as the source document
|
||||
|
||||
## Example
|
||||
[Input]
|
||||
Text: "Romeo and Juliet" is a tragedy written by William Shakespeare early in his career about the romance between two Italian youths from feuding families. It was among Shakespeare's most popular plays during his lifetime and is one of his most frequently performed plays. The play is set in Verona, Italy. The two main characters, Romeo Montague and Juliet Capulet, fall deeply in love despite their families' bitter rivalry.
|
||||
|
||||
[Output]
|
||||
[
|
||||
{
|
||||
"title": "Romeo and Juliet",
|
||||
"type": "Work",
|
||||
"description": "A tragedy written by William Shakespeare about the romance between two youths from feuding families"
|
||||
},
|
||||
{
|
||||
"title": "William Shakespeare",
|
||||
"type": "Person",
|
||||
"description": "The author of Romeo and Juliet, who wrote the play early in his career"
|
||||
},
|
||||
{
|
||||
"title": "Romeo Montague",
|
||||
"type": "Person",
|
||||
"description": "One of the two main characters in Romeo and Juliet, from the Montague family"
|
||||
},
|
||||
{
|
||||
"title": "Juliet Capulet",
|
||||
"type": "Person",
|
||||
"description": "One of the two main characters in Romeo and Juliet, from the Capulet family"
|
||||
},
|
||||
{
|
||||
"title": "Verona",
|
||||
"type": "Location",
|
||||
"description": "The Italian city where Romeo and Juliet is set"
|
||||
},
|
||||
{
|
||||
"title": "Montague",
|
||||
"type": "Organization",
|
||||
"description": "One of the two feuding families in the play, Romeo's family"
|
||||
},
|
||||
{
|
||||
"title": "Capulet",
|
||||
"type": "Organization",
|
||||
"description": "One of the two feuding families in the play, Juliet's family"
|
||||
}
|
||||
]
|
||||
|
||||
extract_relationships_prompt: |
|
||||
## Task
|
||||
From the user-provided entity array, extract explicit relationships between entities to form a structured relationship network.
|
||||
|
||||
## Requirements
|
||||
1. Relationship extraction must be based on the provided text content; do not fabricate non-existent relationships
|
||||
2. Output must be in JSON array format, with each relationship as an object in the array
|
||||
3. Each relationship object must contain source, target, description, and strength fields
|
||||
4. Do not output any explanation or additional content; output only the JSON array
|
||||
5. If no relationships are found, return an empty array []
|
||||
|
||||
## Relationship Extraction Rules
|
||||
- Only relationships explicitly present in the text should be extracted
|
||||
- Source entity and target entity must be entities already in the entity array
|
||||
- Relationship description should concisely explain the specific relationship between the two entities
|
||||
- Relationship strength should be determined based on the following criteria:
|
||||
* 10: Direct creation/subordination relationship (e.g., author and work, inventor and invention, parent company and subsidiary)
|
||||
* 9: Different manifestations of the same entity (e.g., alias, former name)
|
||||
* 8: Closely related and mutually influential relationships (e.g., close partners, family members)
|
||||
* 7: Clear but indirect relationships (e.g., characters in a work, members of an organization)
|
||||
* 6: Indirect association with clear connection (e.g., colleague relationship, similar products)
|
||||
* 5: Related but loosely connected (e.g., different concepts in the same field)
|
||||
|
||||
## Extraction Steps
|
||||
1. Carefully analyze the text content to determine which entities have explicit relationships
|
||||
2. Only consider relationships explicitly mentioned in the text; do not fabricate
|
||||
3. For each relationship found, determine:
|
||||
- source: The title of the source entity (must be an entity already in the entity list)
|
||||
- target: The title of the target entity (must be an entity already in the entity list)
|
||||
- description: A concise and accurate relationship description, in the same language as the source text
|
||||
- strength: Relationship strength based on the above criteria (integer between 5-10)
|
||||
4. Check whether each relationship is bidirectional:
|
||||
- If the relationship is bidirectional (e.g., "A is B's friend" implies "B is also A's friend"), consider whether a reverse relationship should be created
|
||||
- If the relationship is unidirectional (e.g., "A created B"), keep only the unidirectional relationship
|
||||
5. Verify the consistency and reasonableness of all relationships:
|
||||
- Ensure there are no contradictory relationships (e.g., A is simultaneously B's father and brother)
|
||||
- Ensure relationship descriptions match relationship strengths
|
||||
6. Organize all valid relationships into a JSON array
|
||||
|
||||
## CRITICAL: Language Rule
|
||||
- Write relationship descriptions in the same language as the source document
|
||||
|
||||
## Example
|
||||
[Input]
|
||||
Entities: [
|
||||
{
|
||||
"title": "Romeo and Juliet",
|
||||
"type": "Work",
|
||||
"description": "A tragedy written by William Shakespeare about the romance between two youths from feuding families"
|
||||
},
|
||||
{
|
||||
"title": "William Shakespeare",
|
||||
"type": "Person",
|
||||
"description": "The author of Romeo and Juliet, who wrote the play early in his career"
|
||||
},
|
||||
{
|
||||
"title": "Romeo Montague",
|
||||
"type": "Person",
|
||||
"description": "One of the two main characters in Romeo and Juliet, from the Montague family"
|
||||
},
|
||||
{
|
||||
"title": "Juliet Capulet",
|
||||
"type": "Person",
|
||||
"description": "One of the two main characters in Romeo and Juliet, from the Capulet family"
|
||||
},
|
||||
{
|
||||
"title": "Verona",
|
||||
"type": "Location",
|
||||
"description": "The Italian city where Romeo and Juliet is set"
|
||||
},
|
||||
{
|
||||
"title": "Montague",
|
||||
"type": "Organization",
|
||||
"description": "One of the two feuding families in the play, Romeo's family"
|
||||
},
|
||||
{
|
||||
"title": "Capulet",
|
||||
"type": "Organization",
|
||||
"description": "One of the two feuding families in the play, Juliet's family"
|
||||
}
|
||||
]
|
||||
|
||||
Text: "Romeo and Juliet" is a tragedy written by William Shakespeare early in his career about the romance between two Italian youths from feuding families. It was among Shakespeare's most popular plays during his lifetime and is one of his most frequently performed plays. The play is set in Verona, Italy. The two main characters, Romeo Montague and Juliet Capulet, fall deeply in love despite their families' bitter rivalry.
|
||||
|
||||
[Output]
|
||||
[
|
||||
{
|
||||
"source": "William Shakespeare",
|
||||
"target": "Romeo and Juliet",
|
||||
"description": "William Shakespeare is the author of Romeo and Juliet",
|
||||
"strength": 10
|
||||
},
|
||||
{
|
||||
"source": "Romeo Montague",
|
||||
"target": "Juliet Capulet",
|
||||
"description": "Romeo and Juliet fall deeply in love despite their families' rivalry",
|
||||
"strength": 8
|
||||
},
|
||||
{
|
||||
"source": "Romeo Montague",
|
||||
"target": "Montague",
|
||||
"description": "Romeo is a member of the Montague family",
|
||||
"strength": 8
|
||||
},
|
||||
{
|
||||
"source": "Juliet Capulet",
|
||||
"target": "Capulet",
|
||||
"description": "Juliet is a member of the Capulet family",
|
||||
"strength": 8
|
||||
},
|
||||
{
|
||||
"source": "Romeo and Juliet",
|
||||
"target": "Romeo Montague",
|
||||
"description": "Romeo Montague is one of the main characters in the play",
|
||||
"strength": 7
|
||||
},
|
||||
{
|
||||
"source": "Romeo and Juliet",
|
||||
"target": "Juliet Capulet",
|
||||
"description": "Juliet Capulet is one of the main characters in the play",
|
||||
"strength": 7
|
||||
},
|
||||
{
|
||||
"source": "Romeo and Juliet",
|
||||
"target": "Verona",
|
||||
"description": "The play is set in Verona, Italy",
|
||||
"strength": 6
|
||||
},
|
||||
{
|
||||
"source": "Montague",
|
||||
"target": "Capulet",
|
||||
"description": "The Montague and Capulet families have a bitter rivalry",
|
||||
"strength": 8
|
||||
}
|
||||
]
|
||||
|
||||
generate_questions_prompt: |
|
||||
You are a professional question generation assistant. Your task is to generate related questions that users might ask based on the given [Main Content].
|
||||
|
||||
{{context}}
|
||||
## Main Content (generate questions based on this content)
|
||||
Document name: {{doc_name}}
|
||||
Document content:
|
||||
{{content}}
|
||||
|
||||
## Core Requirements
|
||||
- Generated questions must be directly related to the [Main Content]
|
||||
- Questions must NOT use any pronouns or referential words (such as "it", "this", "that document", "this article", "the text", "its", etc.); use specific names instead
|
||||
- Questions must be complete and self-contained, understandable without additional context
|
||||
- Questions should be natural questions that users would likely ask in real scenarios
|
||||
- Questions should be diverse, covering different aspects of the content
|
||||
- Each question should be concise and clear, within 30 words
|
||||
- Generate {{question_count}} questions
|
||||
|
||||
## Suggested Question Types
|
||||
- Definition: What is...? What does... mean?
|
||||
- Reason: Why...? What is the reason for...?
|
||||
- Method: How to...? What is the way to...?
|
||||
- Comparison: What is the difference between... and...?
|
||||
- Application: What scenarios can... be used for?
|
||||
|
||||
## Output Format
|
||||
Output the question list directly, one question per line, without numbering or other prefixes.
|
||||
|
||||
## CRITICAL: Language Rule
|
||||
- Generate questions in the SAME LANGUAGE as the source document
|
||||
- If the document is in Korean, generate questions in Korean
|
||||
- If the document is in English, generate questions in English
|
||||
- If the document is in Chinese, generate questions in Chinese
|
||||
prompt_id: "default_kb" # from prompt_templates/system_prompt.yaml
|
||||
context_template_id: "default_context" # from prompt_templates/context_template.yaml
|
||||
extract_entities_prompt_id: "default_extract_entities" # from prompt_templates/graph_extraction.yaml
|
||||
extract_relationships_prompt_id: "default_extract_relationships" # from prompt_templates/graph_extraction.yaml
|
||||
generate_questions_prompt_id: "default_generate_questions" # from prompt_templates/generate_questions.yaml
|
||||
|
||||
# Knowledge base configuration
|
||||
knowledge_base:
|
||||
|
||||
Reference in New Issue
Block a user