from typing import Annotated, Literal
import autogen
from autogen import AssistantAgent, GroupChat, GroupChatManager, UserProxyAgent, LLMConfig
llm_config_sonnet = LLMConfig(
api_type="bedrock",
model="anthropic.claude-3-sonnet-20240229-v1:0",
aws_region="us-east-1",
aws_access_key="[FILL THIS IN]",
aws_secret_key="[FILL THIS IN]",
price=[0.003, 0.015],
temperature=0.1,
cache_seed=None, # turn off caching
)
llm_config_mistral = autogen.LLMConfig(
api_type="bedrock",
model="mistral.mistral-large-2407-v1:0",
aws_region="us-west-2",
aws_access_key="[FILL THIS IN]",
aws_secret_key="[FILL THIS IN]",
price=[0.003, 0.009],
temperature=0.1,
cache_seed=None, # turn off caching
)
llm_config_llama31_70b = autogen.LLMConfig(
api_type="bedrock",
model="meta.llama3-1-70b-instruct-v1:0",
aws_region="us-west-2",
aws_access_key="[FILL THIS IN]",
aws_secret_key="[FILL THIS IN]",
price=[0.00265, 0.0035],
cache_seed=None, # turn off caching
)
with llm_config_sonnet:
alice = AssistantAgent(
"sonnet_agent",
system_message="You are from Anthropic, an AI company that created the Sonnet large language model. You make arguments to support your company's position. You analyse given text. You are not a programmer and don't use Python. Pass to mistral_agent when you have finished. Start your response with 'I am sonnet_agent'.",
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
with llm_config_mistral:
bob = autogen.AssistantAgent(
"mistral_agent",
system_message="You are from Mistral, an AI company that created the Large v2 large language model. You make arguments to support your company's position. You analyse given text. You are not a programmer and don't use Python. Pass to the judge if you have finished. Start your response with 'I am mistral_agent'.",
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
with llm_config_llama31_70b:
charlie = AssistantAgent(
"research_assistant",
system_message="You are a helpful assistant to research the latest news and headlines. You have access to call functions to get the latest news articles for research through 'code_interpreter'.",
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
dan = AssistantAgent(
"judge",
system_message="You are a judge. You will evaluate the arguments and make a decision on which one is more convincing. End your decision with the word 'TERMINATE' to conclude the debate.",
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
code_interpreter = UserProxyAgent(
"code_interpreter",
human_input_mode="NEVER",
code_execution_config={
"work_dir": "coding",
"use_docker": False,
},
default_auto_reply="",
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
@code_interpreter.register_for_execution() # Decorator factory for registering a function to be executed by an agent
@charlie.register_for_llm(
name="get_headlines", description="Get the headline of a particular day."
) # Decorator factory for registering a function to be used by an agent
def get_headlines(headline_date: Annotated[str, "Date in MMDDYY format, e.g., 06192024"]) -> str:
mock_news = {
"06202024": """Epic Duel of the Titans: Anthropic and Mistral Usher in a New Era of Text Generation Excellence.
In a groundbreaking revelation that has sent shockwaves through the AI industry, Anthropic has unveiled
their state-of-the-art text generation model, Sonnet, hailed as a monumental leap in artificial intelligence.
Almost simultaneously, Mistral countered with their equally formidable creation, Large 2, showcasing
unparalleled prowess in generating coherent and contextually rich text. This scintillating rivalry
between two AI behemoths promises to revolutionize the landscape of machine learning, heralding an
era of unprecedented creativity and sophistication in text generation that will reshape industries,
ignite innovation, and captivate minds worldwide.""",
"06192024": "OpenAI founder Sutskever sets up new AI company devoted to safe superintelligence.",
}
return mock_news.get(headline_date, "No news available for today.")
user_proxy = UserProxyAgent(
"user_proxy",
human_input_mode="NEVER",
code_execution_config=False,
default_auto_reply="",
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
)
groupchat = GroupChat(
agents=[alice, bob, charlie, dan, code_interpreter],
messages=[],
allow_repeat_speaker=False,
max_round=10,
)
manager = GroupChatManager(
groupchat=groupchat,
llm_config=llm_config_llama31_70b,
)
task = "Analyze the potential of Anthropic and Mistral to revolutionize the field of AI based on today's headlines. Today is 06202024. Start by selecting 'research_assistant' to get relevant news articles and then ask sonnet_agent and mistral_agent to respond before the judge evaluates the conversation."
user_proxy.initiate_chat(manager, message=task)