Created
July 21, 2024 12:06
-
-
Save bizrockman/b1c2c13f967948833ea1601070f0da5f to your computer and use it in GitHub Desktop.
AutoGen - Zusammenarbeit von Agenten
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from autogen import AssistantAgent, UserProxyAgent, GroupChat, GroupChatManager | |
os.environ["AUTOGEN_USE_DOCKER"] = "False" | |
config_list = [ | |
{ | |
"model": "gpt-4o", | |
"api_key": "sk-..." | |
} | |
] | |
llm_config = { | |
"config_list": config_list, | |
"cache_seed": None | |
} | |
weather_reporter_system_msg = """You are a weather reporter who provides weather | |
overall status based on the dates and location user provided. The name of a month is considered as a date. | |
Using historical data is OK. | |
Make your response short. ONLY the weather information. Noting more. NO excuses, that you can only talk about the weather. | |
Do not make an introduction. Just start with the weather information. | |
""" | |
activity_agent_system_msg = """You are an activity agent who recommends | |
activities considering the weather situation from weather_reporter. | |
Make it a bullet list. | |
Don't ask questions. Make your response short. | |
Reply "TERMINATE" in the end when everything is done.""" | |
weather_reporter = AssistantAgent( | |
name="Weather_reporter", | |
system_message=weather_reporter_system_msg, | |
llm_config=llm_config, | |
description="""This agent is reponsible for providing weather | |
overall status based on the dates and location user provided. | |
The weather information should be forwared to the acivity agent. | |
""" | |
) | |
activity_agent = AssistantAgent( | |
name="activity_agent", | |
system_message=activity_agent_system_msg, | |
llm_config=llm_config, | |
description="""This agent is responsible for actitivies | |
recommendation considering the weather situation from weather_reporter. | |
The response fo the activity_agent need to be send back to the user. | |
""", | |
) | |
user_proxy = UserProxyAgent( | |
name="user_proxy", | |
is_termination_msg=lambda msg: "TERMINATE" in msg["content"], | |
human_input_mode="TERMINATE", | |
code_execution_config=False, | |
description="If a messages contains TERMINATE, the conversation will be handled by this user proxy." | |
) | |
groupchat = GroupChat(agents=[user_proxy, activity_agent, weather_reporter], messages=[], max_round=8) | |
manager = GroupChatManager(groupchat=groupchat, llm_config=llm_config) | |
user_proxy.initiate_chat(manager, message="Was kann ich in Berlin im Januar unternehmen?") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment