分工合作:建立專家型代理
你正在幫妹妹申請電腦科學學程。要處理的事情很多:查學校、比較課程、還要寫出有說服力的申請文章。
為了簡化流程,你決定建立兩個專門的代理:
- 一個負責研究大學與入學要求
- 一個協助撰寫吸引人的申請文章
你可以使用 CodeAgent 與 WebSearchTool 類別,以及一個已預先設定好的 model。
本練習屬於課程
使用 Hugging Face smolagents 的 AI 代理
練習說明
- 在第一個代理中,將
tools參數設為包含WebSearchTool。 - 仍在第一個代理中,提供一個
name字串,將它標示為學校研究代理。 - 在第二個代理中,將
model參數設為使用提供的 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"
)