Skip to main content

OpenAI plugin for vision agents

Project description

OpenAI Plugin for GetStream

This package provides OpenAI integration for the GetStream plugin ecosystem.

It enables features such as:

  • Real-time transcription and language processing using OpenAI models
  • Easy integration with other GetStream plugins and services
  • Function calling capabilities for dynamic interactions

Installation

pip install getstream-plugins-openai

Usage

from getstream.plugins.openai import OpenAIRealtime

# Initialize with API key
sts = OpenAIRealtime(api_key="your_openai_api_key", voice="alloy")

# Connect to a call
async with await sts.connect(call, agent_user_id="assistant") as connection:
    # Send user message
    await sts.send_user_message("Hello, how can you help me?")

    # Request assistant response
    await sts.request_assistant_response()

Function Calling

The OpenAI Realtime API supports function calling, allowing the assistant to invoke custom functions you define. This enables dynamic interactions like:

  • Database queries
  • API calls to external services
  • File operations
  • Custom business logic

Example with Function Calling

from getstream.plugins.openai import OpenAIRealtime

# Define your functions
def get_weather(location: str) -> str:
    """Get current weather for a location"""
    # Your weather API logic here
    return f"Weather in {location}: Sunny, 72°F"

def send_email(to: str, subject: str, body: str) -> str:
    """Send an email"""
    # Your email sending logic here
    return f"Email sent to {to} with subject: {subject}"

# Initialize with functions
sts = OpenAIRealtime(
    api_key="your_openai_api_key",
    voice="alloy",
    functions=[
        {
            "name": "get_weather",
            "description": "Get current weather information",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {"type": "string", "description": "City name"}
                },
                "required": ["location"]
            }
        },
        {
            "name": "send_email",
            "description": "Send an email to someone",
            "parameters": {
                "type": "object",
                "properties": {
                    "to": {"type": "string", "description": "Recipient email"},
                    "subject": {"type": "string", "description": "Email subject"},
                    "body": {"type": "string", "description": "Email body"}
                },
                "required": ["to", "subject", "body"]
            }
        }
    ]
)

async with await sts.connect(call, agent_user_id="assistant") as connection:
    await sts.send_user_message("What's the weather like in San Francisco?")
    await sts.request_assistant_response()

    # The assistant can now call your functions and you can respond with results
    # await sts.send_function_call_output("call_id", "function_result")

Requirements

  • Python 3.10+
  • openai[realtime] api
  • GetStream SDK

License

MIT

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

vision_agents_plugins_openai-0.1.14.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

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

vision_agents_plugins_openai-0.1.14-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file vision_agents_plugins_openai-0.1.14.tar.gz.

File metadata

File hashes

Hashes for vision_agents_plugins_openai-0.1.14.tar.gz
Algorithm Hash digest
SHA256 f6c628a4d343fddf555cc83aa6d986ed72571e47b5488e4acea8f7959a4ccd15
MD5 2adff23e14ae78c403abe751daa11ec0
BLAKE2b-256 7491cf272e736ccab8e81d7ac93b9796cd2ef9e8307abb5579d992c33fb79536

See more details on using hashes here.

File details

Details for the file vision_agents_plugins_openai-0.1.14-py3-none-any.whl.

File metadata

File hashes

Hashes for vision_agents_plugins_openai-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 29a7e460238c7d602c98248196f5aa78cac464e83538efd306ebad90869b8b61
MD5 e77fa2fee548ab1d20897b0abe249858
BLAKE2b-256 0d98a9e418565b1bf23271603338ae6e18f85931063ddea5d43d33a0a867a603

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