Skip to main content

Video SDK Agents

Project description

VideoSDK Agents

Agents Framework on top of VideoSDK's architecture.

Installation

pip install videosdk-agents

Visit https://docs.videosdk.live/ai_agents/introduction for Quickstart, Examples and Detailed Documentation.

Usage

import asyncio
from videosdk.agents import Agent, AgentSession, RealTimePipeline, function_tool, WorkerJob, RoomOptions, JobContext
from videosdk.plugins.openai import OpenAIRealtime, OpenAIRealtimeConfig
from openai.types.beta.realtime.session import InputAudioTranscription, TurnDetection


class MyVoiceAgent(Agent):
    def __init__(self):
        super().__init__(
            instructions="You are a helpful voice assistant that can answer questions and help with tasks.",
        )

    async def on_enter(self) -> None:
        await self.session.say("How can i assist you today?")

async def entrypoint(ctx: JobContext):
    print("Starting connection test...")
    print(f"Job context: {jobctx}")
    
    model = OpenAIRealtime(
        model="gpt-4o-realtime-preview",
        config=OpenAIRealtimeConfig( modalities=["text", "audio"] )
    )
    pipeline = RealTimePipeline(model=model)
    session = AgentSession(
        agent=MyVoiceAgent(), 
        pipeline=pipeline,
        context=jobctx
    )

    try:
        await ctx.connect()
        await session.start()
        print("Connection established. Press Ctrl+C to exit.")
        await asyncio.Event().wait()
    except KeyboardInterrupt:
        print("\nShutting down gracefully...")
    finally:
        await session.close()
        await ctx.shutdown()


def make_context() -> JobContext:
    room_options = RoomOptions(room_id="<meeting_id>", name="Sandbox Agent", playground=True)
    
    return JobContext(
        room_options=room_options
        )


if __name__ == "__main__":
    job = WorkerJob(job_func=entryPoint, jobctx=make_context)
    job.start()

Project details


Release history Release notifications | RSS feed

This version

1.0.3

Download files

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

Source Distribution

videosdk_agents-1.0.3.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

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

videosdk_agents-1.0.3-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

File details

Details for the file videosdk_agents-1.0.3.tar.gz.

File metadata

  • Download URL: videosdk_agents-1.0.3.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for videosdk_agents-1.0.3.tar.gz
Algorithm Hash digest
SHA256 1b4eed6ad1d21641fcc6430ef267c5049bc28e5ec52fe208eaab74ca6f389dae
MD5 83d7f0a3518f73a5950fa5a2d51e506b
BLAKE2b-256 2a3b276bc04c6dfbf6aa0d48f368202202a3a9633f0b485554f40c4344e3d879

See more details on using hashes here.

File details

Details for the file videosdk_agents-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for videosdk_agents-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0c9d06daf8c7b36b4b77a16af47795ffe3c7a796f122b1edf53cbf7c390806aa
MD5 aa666e985a98d2db55dd6f01b600c264
BLAKE2b-256 81e5e2a46df898b599e84aac8bccaf3464b0449cfe86472a797195aaff3d57f4

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