forked from tylerprogramming/ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added code for creating your first agents
- Loading branch information
1 parent
4385244
commit 3cc7561
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: <name of the file>.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. """) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 # <name of the file>.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 | ||
""") |