Travel Planning: end-to-end 멀티에이전트 응용 예제
Travel Planning: end-to-end 멀티에이전트 응용 예제
이번엔 AgentChat을 사용해 정교한 여행 플래닝 시스템을 만드는 과정을 살펴볼게요. 이 여행 플래너는 각각 특정 역할을 가진 여러 AI 에이전트를 사용해서, 종합적인 여행 일정을 공동으로 만들어요. 여러 에이전트가 역할을 나눠 협업하는 전형적인 end-to-end 예제예요.
출처: 공식문서
먼저 필요한 모듈을 import 해볼게요.
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
에이전트 정의하기
다음 섹션에서는 여행 플래닝 팀에서 쓰일 에이전트들을 정의할게요.
model_client = OpenAIChatCompletionClient(model="gpt-4o")
planner_agent = AssistantAgent(
"planner_agent",
model_client=model_client,
description="A helpful assistant that can plan trips.",
system_message="You are a helpful assistant that can suggest a travel plan for a user based on their request.",
)
local_agent = AssistantAgent(
"local_agent",
model_client=model_client,
description="A local assistant that can suggest local activities or places to visit.",
system_message="You are a helpful assistant that can suggest authentic and interesting local activities or places to visit for a user and can utilize any context information provided.",
)
language_agent = AssistantAgent(
"language_agent",
model_client=model_client,
description="A helpful assistant that can provide language tips for a given destination.",
system_message="You are a helpful assistant that can review travel plans, providing feedback on important/critical tips about how best to address language or communication challenges for the given destination. If the plan already includes language tips, you can mention that the plan is satisfactory, with rationale.",
)
travel_summary_agent = AssistantAgent(
"travel_summary_agent",
model_client=model_client,
description="A helpful assistant that can summarize the travel plan.",
system_message="You are a helpful assistant that can take in all of the suggestions and advice from the other agents and provide a detailed final travel plan. You must ensure that the final plan is integrated and complete. YOUR FINAL RESPONSE MUST BE THE COMPLETE PLAN. When the plan is complete and all perspectives are integrated, you can respond with TERMINATE.",
)
termination = TextMentionTermination("TERMINATE")
group_chat = RoundRobinGroupChat(
[planner_agent, local_agent, language_agent, travel_summary_agent], termination_condition=termination
)
await Console(group_chat.run_stream(task="Plan a 3 day trip to Nepal."))
await model_client.close()
여기서 네 명의 에이전트가 각자 다른 역할(전체 일정, 현지 활동, 언어 팁, 최종 요약)을 맡고, RoundRobinGroupChat으로 순서대로 돌아가며 협업해요. 마지막 요약 에이전트가 TERMINATE라고 응답하면 TextMentionTermination 조건이 팀 실행을 종료하죠.
더 알아보기 (Learn more)
- 라운드로빈·셀렉터 등 팀의 다양한 형태는 팀 튜토리얼을 참고하세요.
- 종료 조건을 다루는 방법은 종료 조건 튜토리얼을 확인하세요.
- 웹서치와 주식 분석을 결합한 더 복잡한 end-to-end 예제는 Company Research를 보세요.