diff --git a/_create_first_agents/first_agents.py b/_create_first_agents/first_agents.py new file mode 100644 index 0000000..e58f61e --- /dev/null +++ b/_create_first_agents/first_agents.py @@ -0,0 +1,33 @@ +import autogen + +config_list = [ + { + "model": "gpt-3.5-turbo", # or gpt-3.5-turbo + "api_key": "sk-proj-1111" + } +] + +user_proxy = autogen.UserProxyAgent( + "user", + code_execution_config={ + "work_dir": "coding", + "use_docker": False + }, + human_input_mode="TERMINATE", + is_termination_msg=lambda msg: "TERMINATE" in msg["content"], +) + +engineer = autogen.AssistantAgent( + "engineer", + llm_config={ + "config_list": config_list + }, + system_message="You are a 10x Python Engineer. You only code in Python. You create excellent front-end " + "developer. Make sure to have # filename: .py as the first line after the triple tick marks. " + "When you are done, reply with TERMINATE.", +) + +user_proxy.initiate_chat( + engineer, + message="""I want you to create two different python methods for me in 1 file. 1 will just generate a random + number, and the other will take in a number and then reverse it. """) diff --git a/_create_first_agents/group_chat.py b/_create_first_agents/group_chat.py new file mode 100644 index 0000000..4587443 --- /dev/null +++ b/_create_first_agents/group_chat.py @@ -0,0 +1,63 @@ +import autogen +from autogen.coding import LocalCommandLineCodeExecutor + +config_list = [ + { + "model": "gpt-4", + "api_key": "sk-proj-1111" + } +] + +executor = LocalCommandLineCodeExecutor( + timeout=10, # Timeout for each code execution in seconds. + work_dir="code" # the directory +) + +user_proxy = autogen.UserProxyAgent( + "user", + code_execution_config={"executor": executor}, + human_input_mode="TERMINATE", + is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"), +) + +planner = autogen.AssistantAgent( + "planner", + llm_config={ + "config_list": config_list + }, + system_message="You are a planner. When you get the message, your job is to come up with a plan. " + "When you are done, reply with TERMINATE" +) + +engineer = autogen.AssistantAgent( + "engineer", + llm_config={ + "config_list": config_list + }, + system_message="You are a 10x Python Engineer. You only code in Python. You create excellent front-end " + "developer. When you are done, reply with " + "TERMINATE. Make sure to have # .py after the ``` on each piece of code.", +) + +critic = autogen.AssistantAgent( + "critic", + llm_config={ + "config_list": config_list + }, + system_message="Your job is to critique the plan and code, and modify anything if necessary. If it looks good " + "then just let it be. When you are done, reply with TERMINATE", +) + +group_chat = autogen.GroupChat(agents=[user_proxy, planner, engineer, critic], messages=[], max_round=15) +manager = autogen.GroupChatManager(groupchat=group_chat, llm_config={"config_list": config_list}) + +user_proxy.initiate_chat( + manager, + message=""" + I want you to come up with a plan on how we would create a full front end with: + + 1. multiple html pages + 2. routing to each page and from each page + 3. style with bootstrap + 4. have a button on each page that performs a function that will give a random number when clicked + """)