Skip to main content

Model adapters for OpenAI Agents SDK

Project description

Agents SDK Models 🤖🔌

PyPI Downloads

Python 3.9+ OpenAI Agents 0.0.9

A collection of model adapters for OpenAI Agents SDK, allowing you to use various LLM providers with a unified interface! 🚀

🌟 Features

  • 🔄 Unified Interface: Use the same OpenAI Agents SDK interface with multiple model providers
  • 🧩 Multiple Models: Support for Ollama, Google Gemini, and Anthropic Claude
  • 📊 Structured Output: All models support structured output using Pydantic models

🛠️ Installation

From PyPI (Recommended)

# Install from PyPI
pip install agents-sdk-models

# For examples with structured output
pip install agents-sdk-models[examples]

From Source

# Clone the repository
git clone https://github.com/kitfactory/agents-sdk-models.git
cd agents-sdk-models

# Create and activate a virtual environment
python -m venv .venv
.venv\Scripts\activate  # Windows
source .venv/bin/activate  # Linux/Mac

# Install the package in development mode
pip install -e .

🚀 Quick Start

Ollama

import asyncio
from agents import Agent, Runner
from agents_sdk_models import OllamaModel

async def main():
    # Initialize the Ollama model
    model = OllamaModel(
        model="llama3",  # or any other model available in your Ollama instance
        temperature=0.7
    )
    
    # Create an agent with the model
    agent = Agent(
        name="Assistant",
        instructions="You are a helpful assistant.",
        model=model
    )
    
    # Run the agent
    response = await Runner.run(agent, "What is your name and what can you do?")
    print(response.final_output)

if __name__ == "__main__":
    asyncio.run(main())

Google Gemini

import asyncio
import os
from agents import Agent, Runner
from agents_sdk_models import GeminiModel

async def main():
    # Get API key from environment variable
    api_key = os.environ.get("GOOGLE_API_KEY")
    
    # Initialize the Gemini model
    model = GeminiModel(
        model="gemini-1.5-pro",
        temperature=0.7,
        api_key=api_key
    )
    
    # Create an agent with the model
    agent = Agent(
        name="Assistant",
        instructions="You are a helpful assistant.",
        model=model
    )
    
    # Run the agent
    response = await Runner.run(agent, "What is your name and what can you do?")
    print(response.final_output)

if __name__ == "__main__":
    asyncio.run(main())

Anthropic Claude

import asyncio
import os
from agents import Agent, Runner
from agents_sdk_models import ClaudeModel

async def main():
    # Get API key from environment variable
    api_key = os.environ.get("ANTHROPIC_API_KEY")
    
    # Initialize the Claude model
    model = ClaudeModel(
        model="claude-3-sonnet-20240229",
        temperature=0.7,
        api_key=api_key,
        thinking=True  # Enable thinking for complex reasoning
    )
    
    # Create an agent with the model
    agent = Agent(
        name="Assistant",
        instructions="You are a helpful assistant.",
        model=model
    )
    
    # Run the agent
    response = await Runner.run(agent, "What is your name and what can you do?")
    print(response.final_output)

if __name__ == "__main__":
    asyncio.run(main())

📊 Structured Output

All models support structured output using Pydantic models:

from pydantic import BaseModel
from typing import List

class WeatherInfo(BaseModel):
    location: str
    temperature: float
    condition: str
    recommendation: str

class WeatherReport(BaseModel):
    report_date: str
    locations: List[WeatherInfo]

# Create an agent with structured output
agent = Agent(
    name="Weather Reporter",
    model=model,
    instructions="You are a helpful weather reporter.",
    output_type=WeatherReport
)

# Get structured response
response = await Runner.run(agent, "What's the weather like in Tokyo, Osaka, and Sapporo?")
weather_report = response.final_output  # This is a WeatherReport object

🔧 Supported Environments

  • Operating Systems: Windows, macOS, Linux
  • Python Version: 3.9+
  • Dependencies:
    • openai>=1.73.0
    • openai-agents==0.0.9
    • pydantic>=2.10, <3 (for examples with structured output)

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agents_sdk_models-0.0.9.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agents_sdk_models-0.0.9-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file agents_sdk_models-0.0.9.tar.gz.

File metadata

  • Download URL: agents_sdk_models-0.0.9.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for agents_sdk_models-0.0.9.tar.gz
Algorithm Hash digest
SHA256 fd33f19a06625bc6b2b5541ba0699084a6e60db5cb2cd8ce227fdfaad6f0dc09
MD5 72a606e5daa6d467a7f4ab642c44fe93
BLAKE2b-256 500aa020553d894f8110adfa563f7e6d85845272601baeaec246e79a6495aa6a

See more details on using hashes here.

File details

Details for the file agents_sdk_models-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for agents_sdk_models-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 a54171551697b99343346ae0298fe01dec25c0ca760e628d932d3feeae9281ff
MD5 dd322d056d19d2a86d7fdc1973f40080
BLAKE2b-256 ae48b5b633f12a74060dea361aa27e2983bc631a99659dd2282fa3d63604efdb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page