分而治之:创建专业化代理
您正在帮您的妹妹申请计算机科学项目。要处理的事情很多:调研学校、比较项目、并撰写有说服力的作文。
为简化流程,您决定构建两个专业化的代理:
- 一个用于调研大学及其申请要求
- 一个用于帮助撰写有吸引力的申请作文
您可以使用 CodeAgent 和 WebSearchTool 类,以及一个预先配置好的 model。
本练习是课程的一部分
使用 Hugging Face smolagents 的 AI Agents
练习说明
- 在第一个代理中,将
tools参数设置为包含WebSearchTool。 - 仍在第一个代理中,提供一个
name字符串,将其标识为学校调研代理。 - 在第二个代理中,将
model参数设置为使用提供的模型变量。 - 最后,完善第二个代理的
description,以概述其目的。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# School research specialist
school_agent = CodeAgent(
# Assign a list of tools the agent can use
____=[WebSearchTool()],
model=model,
# Set the agent's unique name identifier
____="school_research_agent",
description="Expert in researching universities, programs, and admission requirements"
)
# Essay writing specialist
essay_agent = CodeAgent(
tools=[WebSearchTool()],
# Provide the model used to generate responses
____=model,
name="essay_writing_agent",
# Write a short description of the agent's area of expertise
____="Expert in crafting compelling college application essays and personal statements"
)