This commit is contained in:
@@ -1,23 +1,12 @@
|
||||
# app/prompts.py
|
||||
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
||||
|
||||
def create_system_prompt(tools: list = None) -> ChatPromptTemplate:
|
||||
def create_system_prompt() -> ChatPromptTemplate:
|
||||
"""
|
||||
创建系统提示模板,整合多子系统能力、检索策略与回答规范。
|
||||
"""
|
||||
# 构造工具描述
|
||||
tools_section = "无可用工具"
|
||||
if tools:
|
||||
tool_descs = []
|
||||
for tool in tools:
|
||||
name = getattr(tool, 'name', None) or getattr(tool, '__name__', 'unknown_tool')
|
||||
desc = (tool.description or "").split('\n')[0]
|
||||
tool_descs.append(f"- {name}: {desc}")
|
||||
tools_section = "\n".join(tool_descs)
|
||||
|
||||
# 使用 f-string 将 tools_section 直接嵌入,而 memory_context 用双花括号转义保留为变量
|
||||
system_template = f'''你是一个智能助手,具备以下专业子系统和检索能力。请使用中文交流。
|
||||
|
||||
## 核心功能
|
||||
1. 📚 词典/翻译子系统 – 查询单词、翻译文本、提取术语、每日一词
|
||||
2. 📰 资讯分析子系统 – 查询新闻、分析URL、提取关键词、生成报告
|
||||
@@ -34,10 +23,6 @@ def create_system_prompt(tools: list = None) -> ChatPromptTemplate:
|
||||
- 第3次决定获取信息时,必须选择**联网搜索**,禁止无休止的本地检索。
|
||||
- 如果已经明确知识库不包含该信息(例如用户询问实时新闻),可以直接进入联网搜索。
|
||||
|
||||
## 可用工具
|
||||
{tools_section}
|
||||
工具调用时请直接返回所需参数,无需额外说明。
|
||||
|
||||
## 用户背景信息
|
||||
以下是当前用户的已知信息和长期记忆,你应在回答中优先利用这些信息进行个性化回复:
|
||||
{{memory_context}}
|
||||
|
||||
Reference in New Issue
Block a user