Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Simplify the AgentChat quickstart example and providing one code snippet for each model provider #5348

Open
ekzhu opened this issue Feb 3, 2025 · 0 comments
Labels
documentation Improvements or additions to documentation needs-triage
Milestone

Comments

@ekzhu
Copy link
Collaborator

ekzhu commented Feb 3, 2025

  • The code example is still a bit complex.
  • We can provide one code snippet for each major model provider, instead of asking user to edit code, it should just run perfectly.

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()

Repeat this for each model provider:

  • Azure Open AI
  • Azure AI Foundary
  • Gemini
  • Ollama
@ekzhu ekzhu added this to the python-v0.4.6 milestone Feb 3, 2025
@ekzhu ekzhu added the documentation Improvements or additions to documentation label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant