多代理系統入門

使用 Hugging Face smolagents 的 AI 代理

Adel Nehme

VP of AI Curriculum, DataCamp

情境:職涯顧問代理

這個需求包含多項任務:

  • 更新履歷
  • 求職搜尋
  • 面試準備
  • 薪資研究

每個任務都需要不同的工具與流程!

使用 Hugging Face smolagents 的 AI 代理

為何使用多代理系統?

  • 使用一支專業代理團隊
  • 避免超載與混淆

使用 Hugging Face smolagents 的 AI 代理

履歷專家代理

resume_agent = CodeAgent(
    tools=[WebSearchTool(), skill_translator, layout_generator],
    model=InferenceClientModel(),
    instructions="You are an expert in everything related to resumes.",
    name="resume_agent",
    description="Expert in resume writing and skill translation for career transitions"
)
使用 Hugging Face smolagents 的 AI 代理

公司研究專家

company_agent = CodeAgent(
    tools=[WebSearchTool(), background_compatibility_checker],
    model=InferenceClientModel(),
    instructions="You are an expert in everything related to company research",
    name="company_agent",
    description="Expert in researching companies, culture, and hiring practices for job seekers"
)
  • 依同樣模式建立更多專家代理。
使用 Hugging Face smolagents 的 AI 代理

管理者代理

career_manager = CodeAgent(
    tools=[],
    model=InferenceClientModel(model_id="deepseek-ai/DeepSeek-R1"), # Reasoning model
    instructions="You are an advisory agent to help professionals build stellar careers",
    managed_agents=[resume_agent, company_agent, interview_agent, salary_agent]
)
  • 依描述將任務指派給合適的專家。
  • 透過 managed_agents 參數協調 4 個專家代理。
  • 善用具強大推理與協調能力的模型。
使用 Hugging Face smolagents 的 AI 代理

多代理協作編排

result = career_manager.run("I want to switch from marketing to data science. 
Help me update my resume, find companies hiring, prepare for interviews, and understand salaries.")

使用 Hugging Face smolagents 的 AI 代理

一起來練習吧!

使用 Hugging Face smolagents 的 AI 代理

Preparing Video For Download...