0% found this document useful (0 votes)
27 views1 page

Voice AI Assistant Initialization Code

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views1 page

Voice AI Assistant Initialization Code

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

from dotenv import load_dotenv

import os
import uuid
import sys

from livekit import agents


from [Link] import AgentSession, Agent, room_io
from [Link] import (
openai,
noise_cancellation,
silero,
turn_detector,
)

# Add parent directory to path for imports from common


[Link]([Link]([Link]([Link](__file__), '..')))
from common.agent_session_storage import AgentSessionStorage

load_dotenv()

class Assistant(Agent):
def __init__(self) -> None:
super().__init__(instructions="You are a helpful voice AI assistant.")

async def entrypoint(ctx: [Link]):


await [Link]()

session = AgentSession(
llm=[Link](
model="gpt-4o-mini-realtime-preview",
voice="sage",
),
)

# Initialize conversation storage for Supabase


storage = AgentSessionStorage(
session=session,
conversation_id=str(uuid.uuid4()),
user_id="voice_user",
system_prompt="You are a helpful voice AI assistant.",
call_type="inbound"
)
[Link]()

await [Link](
room=[Link],
agent=Assistant(),
)

# Instruct the agent to speak first


await session.generate_reply()

if __name__ == "__main__":
[Link].run_app([Link](entrypoint_fnc=entrypoint))

You might also like