-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationneeds-triage
Milestone
Description
- The code example is still a bit complex.
The new code example:
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient
# Define a tool
async def get_weather(city: str) -> str:
return f"The weather in {city} is 73 degrees and Sunny."
async def main() -> None:
# Define an agent
weather_agent = AssistantAgent(
name="weather_agent",
model_client=OpenAIChatCompletionClient(
model="gpt-4o-2024-08-06",
# api_key="YOUR_API_KEY",
),
tools=[get_weather],
)
# Run a query
stream = weather_agent.run_stream(task="What's the weather like in Seattle, WA")
# Display output in console
await Console(stream)
# NOTE: if running this inside a Python script you'll need to use asyncio.run(main()).
await main()
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationneeds-triage