把检索器包装成工具
函数的 docstring 是 Agent 理解能力边界的重要上下文。
from langchain.tools import tool
@tool
def retrieve_resume(query: str) -> str:
"""Search education, internships, projects, skills and awards."""
return retrieve_resume_context(query)
@tool
def retrieve_agent_guide(topic: str) -> str:
"""Read implementation notes about this Python Agent."""
return AGENT_BUILD_GUIDE
使用 DeepSeek 兼容接口
model = ChatOpenAI(
api_key=os.environ["DEEPSEEK_API_KEY"],
base_url="https://api.deepseek.com",
model="deepseek-chat",
temperature=0.2,
)
让 Agent 自己决定工具
personal_agent = create_agent(
model=model,
tools=[retrieve_resume, retrieve_agent_guide],
system_prompt="回答简历事实前必须检索;没有资料就明确说明。",
name="resume_agent",
)
提示词负责规则,工具负责事实,模型负责判断与表达。三者分开后,更新简历不需要改提示词,替换模型也不需要重写检索器。