Quickstart
This guide will help you get started with AgentOperaโs basic functionality.
๐ Prerequisites
Before starting, make sure you have:
Installed AgentOpera (see installation guide)
Set up your environment variables for LLM API access
๐ Setting Up Environment Variables
AgentOpera uses environment variables for API keys and model configurations.
Configure them as follows:
# OpenAI API Configuration
export MODEL_BASE_URL=https://api.openai.com/v1
export MODEL_API_KEY=your_openai_api_key
export MODEL_ID=gpt-4o # or any other model ID you prefer
๐ Hello World Example
Start with a simple โHello Worldโ example:
import asyncio
import os
from agentopera.chatflow.agents import AssistantAgent
from agentopera.models.openai import OpenAIChatCompletionClient
# Create a model client using the OpenAI API key and model ID
model_client = OpenAIChatCompletionClient(
base_url=os.getenv("MODEL_BASE_URL"),
api_key=os.getenv("MODEL_API_KEY"),
model=os.getenv("MODEL_ID")
)
async def main() -> None:
# Create an assistant agent using the model client
agent = AssistantAgent("assistant", model_client=model_client)
# Run the agent with the task "Say 'Hello World!'"
print(await agent.run(task="Say 'Hello World!'"))
asyncio.run(main())
Save this code to a file (e.g., hello_world.py
) and run it:
python hello_world.py
๐ Next Steps
For more advanced usage, including:
Creating complex agent networks
Implementing custom agents
Deploying agents as services
Refer to our complete documentation.
๐ Acknowledgements
We thank AutoGen by Microsoft for their excellent work, which inspired our Python API implementation. ๐ Original Project: AutoGen
Last updated