Skip to content

Instantly share code, notes, and snippets.

@fadur
Created April 13, 2025 21:50
Show Gist options
  • Save fadur/7badc17c4c48b88fe81ebf47c9a0f25e to your computer and use it in GitHub Desktop.
Save fadur/7badc17c4c48b88fe81ebf47c9a0f25e to your computer and use it in GitHub Desktop.
Autogen - Example.
from autogen import AssistantAgent, UserProxyAgent, tool
@tool
def get_time() -> str:
from datetime import datetime
return datetime.now().isoformat()
user_proxy = UserProxyAgent(name="user_proxy", human_input_mode="NEVER")
assistant = AssistantAgent(
name="assistant",
llm_config={"config_list": [{"model": "gpt-4", "api_key": "your-key"}]},
code_execution_config={"work_dir": "coding"},
)
user_proxy.initiate_chat(
assistant,
message="What time is it?",
tools=[get_time],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment