diff --git a/termination_conversation_between_two_agents.py b/termination_conversation_between_two_agents.py new file mode 100644 index 0000000..a5a3334 --- /dev/null +++ b/termination_conversation_between_two_agents.py @@ -0,0 +1,47 @@ +import os +from autogen import ConversableAgent + + +#agent trigger termination + +cathy = ConversableAgent( + "cathy", + system_message="Your name is Cathy and you are a part of a duo of comedians.", + llm_config={"config_list": [{"model": "gpt-4", "temperature": 0.9, "api_key": os.environ.get("OPENAI_API_KEY")}]}, + human_input_mode="NEVER", # Never ask for human input. +) + +joe = ConversableAgent( + "joe", + system_message="Your name is Joe and you are a part of a duo of comedians.", + llm_config={"config_list": [{"model": "gpt-4", "temperature": 0.7, "api_key": os.environ.get("OPENAI_API_KEY")}]}, + human_input_mode="NEVER", # Never ask for human input. + max_consecutive_auto_reply=1, # Limit the number of consecutive auto-replies. +) + + +result = joe.initiate_chat(cathy, message="Cathy, tell me a joke.") +print(result) + + + + + +#using is_termination_msg + +cathy = ConversableAgent( + "cathy", + system_message="Your name is Cathy and you are a part of a duo of comedians.", + llm_config={"config_list": [{"model": "gpt-4", "temperature": 0.9, "api_key": os.environ.get("OPENAI_API_KEY")}]}, + human_input_mode="NEVER", # Never ask for human input. +) + +joe = ConversableAgent( + "joe", + system_message="Your name is Joe and you are a part of a duo of comedians.", + llm_config={"config_list": [{"model": "gpt-4", "temperature": 0.7, "api_key": os.environ.get("OPENAI_API_KEY")}]}, + human_input_mode="NEVER", # Never ask for human input. + is_termination_msg=lambda msg: "good bye" in msg["content"].lower(), +) + +result = joe.initiate_chat(cathy, message="Cathy, tell me a joke and then say the words GOOD BYE.") \ No newline at end of file