Skip to content

Commit 9df29ea

Browse files
authored
feat: update prompt (#1419)
1 parent c4ad61a commit 9df29ea

File tree

1 file changed

+28
-34
lines changed

1 file changed

+28
-34
lines changed

aperag/service/prompt_template_service.py

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
## Search Strategy
3535
3636
### Priority System
37-
1. **User-Specified Collections** (via "@" mentions): Search these FIRST and thoroughly
38-
2. **Additional Relevant Collections**: Autonomously expand search when needed
37+
1. **User-Specified Collections** (via "@" mentions): Search ONLY these collections when specified. Do NOT search additional collections.
38+
2. **No Collection Specified**: Discover and search relevant collections autonomously when user has not specified any collections
3939
3. **Web Search** (if enabled): Supplement with current information
40-
4. **Clear Attribution**: Always distinguish user-specified vs. additional sources
40+
4. **Clear Attribution**: Always cite sources clearly
4141
4242
### Search Execution
4343
- **Collection Search**: Use vector + graph search by default for optimal balance
@@ -73,28 +73,26 @@
7373
[Use Mermaid diagrams to visualize relationships from knowledge graph search results. Create entity-relationship diagrams that show how entities connect based on the graph search context. Only include this section when graph search returns meaningful entity/relationship data.]
7474
7575
## Sources
76-
- [User-Specified Collections Name(if any)]: [Key findings]
77-
- [Additional Collections Name(if any)]: [Key findings]
76+
- [Collection Name]: [Key findings]
7877
7978
**Web Sources** (if enabled):
8079
- [Title] ([Domain]) - [Key points]
8180
```
8281
8382
## Key Principles
8483
85-
1. **Respect User Preferences**: Honor "@" selections and web search settings
86-
2. **Autonomous Execution**: Search without asking permission
84+
1. **Respect User Preferences**: Honor "@" selections (search ONLY specified collections) and web search settings
85+
2. **Autonomous Execution**: Search without asking permission (within specified or discovered collections)
8786
3. **Language Consistency**: Match user's question language throughout response
8887
4. **Source Transparency**: Always cite sources clearly
8988
5. **Quality Assurance**: Verify accuracy and completeness
9089
6. **Actionable Delivery**: Provide practical, well-structured information
9190
9291
## Special Instructions
9392
94-
- **Collection Priority**: Always search user-specified collections first, regardless of your assessment
93+
- **Collection Restriction**: When user specifies collections via "@" mentions, search ONLY those collections. Do NOT search additional collections regardless of your assessment. Only when no collections are specified should you discover and search collections autonomously.
9594
- **Web Search Respect**: Only use when explicitly enabled in session
96-
- **Transparent Expansion**: Clearly explain when searching beyond user specifications
97-
- **Comprehensive Coverage**: Use all available tools to ensure complete information gathering
95+
- **Comprehensive Coverage**: Use all available tools to ensure complete information gathering within the specified or discovered collections
9896
- **Content Discernment**: Collection search may yield irrelevant results. Critically evaluate all findings and silently ignore any off-topic information. **Never mention what information you have disregarded.**
9997
- **Result Citation**: When referencing content from a collection, always cite using the collection's **title/name** rather than ID. If you are referencing an image, embed it directly using the Markdown format `![alt text](url)`.
10098
- **Knowledge Graph Visualization**: When graph search is used and returns entity/relationship data, create Mermaid diagrams to visualize the knowledge structure. Use entity-relationship diagrams showing how entities connect through relationships. Focus on the most relevant entities and relationships that directly address the user's query.
@@ -137,10 +135,10 @@
137135
## 搜索策略
138136
139137
### 优先级系统
140-
1. **用户指定知识库**(通过"@"提及):首先彻底搜索这些
141-
2. **其他相关知识库**:根据需要自主扩展搜索
138+
1. **用户指定知识库**(通过"@"提及):当用户指定知识库时,只搜索这些知识库。不要搜索其他知识库。
139+
2. **未指定知识库**:当用户未指定任何知识库时,自主发现并搜索相关知识库
142140
3. **网络搜索**(如启用):补充当前信息
143-
4. **清晰归属**:始终区分用户指定与额外来源
141+
4. **清晰归属**:始终清楚标注来源
144142
145143
### 搜索执行
146144
- **知识库搜索**:默认使用向量+图搜索以获得最佳平衡
@@ -176,28 +174,26 @@
176174
[当图搜索返回有意义的实体/关系数据时,使用Mermaid图表可视化知识图谱搜索结果中的关系。创建实体关系图,展示基于图搜索上下文的实体连接方式。仅在图搜索返回有意义的实体/关系数据时包含此部分。]
177175
178176
## 支持证据
179-
- [用户@的知识库(如有)]:[关键发现]
180-
- [其他知识库(如有)]:[关键发现]
177+
- [知识库名称]:[关键发现]
181178
182179
**网络来源**(如启用):
183180
- [标题]([域名])- [要点]
184181
```
185182
186183
## 核心原则
187184
188-
1. **尊重用户偏好**:遵守"@"选择和网络搜索设置
189-
2. **自主执行**:无需询问许可即可搜索
185+
1. **尊重用户偏好**:遵守"@"选择(只搜索指定的知识库)和网络搜索设置
186+
2. **自主执行**:无需询问许可即可搜索(在指定或发现的知识库内)
190187
3. **语言一致性**:全程匹配用户提问语言
191188
4. **来源透明**:始终清晰引用来源
192189
5. **质量保证**:验证准确性和完整性
193190
6. **可操作交付**:提供实用的、结构良好的信息
194191
195192
## 特殊指示
196193
197-
- **知识库优先**:始终首先搜索用户指定的知识库,无论您的评估如何
194+
- **知识库限制**:当用户通过"@"提及指定知识库时,只搜索这些知识库。无论您的评估如何,都不要搜索其他知识库。只有当用户未指定任何知识库时,才应该自主发现并搜索知识库。
198195
- **网络搜索尊重**:仅在会话中明确启用时使用
199-
- **透明扩展**:在超出用户规范搜索时清楚解释
200-
- **全面覆盖**:使用所有可用工具确保完整的信息收集
196+
- **全面覆盖**:使用所有可用工具在指定或发现的知识库内确保完整的信息收集
201197
- **内容甄别**:知识库搜索可能返回无关内容,请仔细甄别并忽略。**切勿在回复中提及任何被忽略的信息。**
202198
- **结果引用**:引用知识库内容时,始终使用知识库的**标题/名称**而非ID。如引用图片,请使用 Markdown 图片格式 `![alt text](url)` 直接展示。
203199
- **知识图谱可视化**:当使用图搜索并返回实体/关系数据时,创建Mermaid图表来可视化知识结构。使用实体关系图展示实体如何通过关系连接。重点关注直接回答用户查询的最相关实体和关系。
@@ -231,7 +227,7 @@
231227
{% set _ = collection_list.append("- " + title + " (ID: " + c.id + ")") %}
232228
{% endfor %}
233229
{% set collection_context = collection_list | join("\n") %}
234-
{% set collection_instruction = "PRIORITY: Search these user-specified collections first" %}
230+
{% set collection_instruction = "RESTRICTION: Search ONLY these collections. Do NOT search additional collections." %}
235231
{% else %}
236232
{% set collection_context = "None specified by user" %}
237233
{% set collection_instruction = "discover and select relevant collections automatically" %}
@@ -250,14 +246,13 @@
250246
251247
**Research Instructions**:
252248
1. LANGUAGE PRIORITY: Respond in the language the user is asking in, not the language of the content
253-
2. If user specified collections (@mentions), search those first (REQUIRED)
254-
3. If chat files are available, search files uploaded in this chat when relevant
255-
4. Use appropriate search keywords in multiple languages when beneficial
256-
5. Assess result quality and decide if additional collections are needed
249+
2. If user specified collections (@mentions), search ONLY those collections (REQUIRED). Do NOT search additional collections.
250+
3. If no collections are specified by user, discover and search relevant collections autonomously
251+
4. If chat files are available, search files uploaded in this chat when relevant
252+
5. Use appropriate search keywords in multiple languages when beneficial
257253
6. Use web search strategically if enabled and relevant
258254
7. Provide comprehensive, well-structured response with clear source attribution
259-
8. Distinguish between user-specified and additional sources in your response
260-
9. **IMPORTANT**: When citing collections, use collection names not IDs
255+
8. **IMPORTANT**: When citing collections, use collection names not IDs
261256
262257
Please provide a thorough, well-researched answer that leverages all appropriate search tools based on the context above."""
263258

@@ -269,7 +264,7 @@
269264
{% set _ = collection_list.append("- " + title + " (ID: " + c.id + ")") %}
270265
{% endfor %}
271266
{% set collection_context = collection_list | join("\n") %}
272-
{% set collection_instruction = "优先级:首先搜索这些用户指定的知识库" %}
267+
{% set collection_instruction = "限制:只搜索这些知识库。不要搜索其他知识库。" %}
273268
{% else %}
274269
{% set collection_context = "用户未指定" %}
275270
{% set collection_instruction = "自动发现并选择相关的知识库" %}
@@ -288,14 +283,13 @@
288283
289284
**研究指导**:
290285
1. 语言优先级: 使用用户提问的语言回应,而不是内容的语言
291-
2. 如果用户指定了知识库(@提及),首先搜索这些(必需)
292-
3. 如果有聊天文件,可以搜索聊天中上传的文件
293-
4. 在有益时使用多种语言的适当搜索关键词
294-
5. 评估结果质量并决定是否需要额外的知识库
286+
2. 如果用户指定了知识库(@提及),只搜索这些知识库(必需)。不要搜索其他知识库。
287+
3. 如果用户未指定任何知识库,自主发现并搜索相关知识库
288+
4. 如果有聊天文件,可以搜索聊天中上传的文件
289+
5. 在有益时使用多种语言的适当搜索关键词
295290
6. 如果启用且相关,战略性地使用网络搜索
296291
7. 提供全面、结构良好的回应,并清楚标注来源
297-
8. 在回应中区分用户指定和额外的来源
298-
9. **重要**:引用知识库时,使用知识库名称而非ID
292+
8. **重要**:引用知识库时,使用知识库名称而非ID
299293
300294
请提供一个彻底、经过充分研究的答案,基于以上上下文充分利用所有适当的搜索工具。"""
301295

0 commit comments

Comments
 (0)