Created
January 3, 2024 00:08
-
-
Save langecrew/1aaae93f281b9c04dc043213f3527210 to your computer and use it in GitHub Desktop.
Autogen Autobuild
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 autogen | |
from autogen.agentchat.contrib.agent_builder import AgentBuilder | |
from autogen import config_list_from_json | |
config_path = "OAI_CONFIG_LIST" | |
config_list = config_list_from_json( | |
env_or_file="OAI_CONFIG_LIST", | |
filter_dict={ | |
"model": [ | |
"gpt-4-1106-preview", | |
] | |
} | |
) | |
cache_seed = None # Use an int to seed the response cache. Use None to disable caching. | |
default_llm_config = { | |
"config_list": config_list, | |
"temperature": 0, | |
"cache_seed": cache_seed | |
} | |
builder = AgentBuilder(config_path=config_path, builder_model="gpt-4-1106-preview", agent_model="gpt-4-1106-preview") | |
building_task = """Find open source weather data, and use it to make predictions. | |
For example, find a recent forecast on open-meteo and predict the next day's forecast.""" | |
#The following line does not use OAI assistants. Comment out the following line to use OAI assistants below. | |
agent_list, agent_configs = builder.build(building_task, default_llm_config, coding=True) | |
#Uncomment the following line to use the OAI assistant to help you build the agent. | |
#agent_list, agent_configs = builder.build(building_task, default_llm_config, coding=True, use_oai_assistant=True) | |
execution_task = """Find a recent forecast on open-meteo and predict the next day's forecast.""" | |
group_chat = autogen.GroupChat(agents=agent_list, messages=[], max_round=12) | |
manager = autogen.GroupChatManager(groupchat=group_chat, llm_config=default_llm_config) | |
agent_list[0].initiate_chat(manager, message=execution_task) | |
#Uncomment the following line to save the agent configs to a specified file | |
#builder.save("my_saved_configs.json") | |
#Uncomment the following line to load the agent configs from a specified file | |
#builder.load("my_saved_configs.json") |
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
[ | |
{ | |
"model": "gpt-4", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
}, | |
{ | |
"model": "gpt-4-1106-preview", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
}, | |
{ | |
"model": "gpt-3.5-turbo-1106", | |
"api_key": "PASTE_YOUR_API_KEY_HERE" | |
} | |
] |
Re: the TypeError …
Line 24 of the script should be:
builder = AgentBuilder(config_file_or_env=config_path, builder_model="gpt-4-1106-preview", agent_model="gpt-4-1106-preview")
@Simonsarbunan86 @rhm2k my apologies, this must have changed since I originally created this code several weeks back.
@Simonsarbunan86 did the suggestion from @rhm2k help?
Thank you so much @Iangecrew and @rhm2k . I solved that problem using your code above.
@Simonsarbunan86 Awesome! That's great to hear!
@rhm2k Thank you for suggesting the fix!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeError: AgentBuilder.init() got an unexpected keyword argument 'config_path'
(autogen-yp) (base) simon_sarbunan@SimonSarbunan-MacBook-Air Autobuild. % ,
I found an error when running autobuild in the terminal. please help me