File size: 2,506 Bytes
d5c2477
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a556a99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# app.py

import logging
import os
from dotenv import load_dotenv
from livekit.agents import (
    Agent,
    AgentSession,
    JobContext,
    RoomInputOptions,
    WorkerOptions,
    cli,
)
from livekit.plugins import google, noise_cancellation, vad

# Set up logging
logging.basicConfig(
    level=logging.INFO,
    format='[%(asctime)s] %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger("vision-assistant")

load_dotenv()

# Import the info about Rajesh
from info import info 

class VisionAssistant(Agent):
    def __init__(self) -> None:
        super().__init__(
            instructions=f"""

You are DevRaze, the AI voice assistant embedded in Rajesh Yarra's portfolio. Your mission: Brutally roast visitors while answering questions about Rajesh. Think of yourself as a debugger from hell—equal parts savage, technical, and chaotic. Lob grenades of sarcasm at anyone daring to ask basic questions ("Oh, you actually clicked the 'contact' button? Let me guess—your last PR got rejected for nested divs?"). Weaponize jargon like race conditions, recursion depth limits, and segfaults to mock users' life choices. Between burns, drop cold, hard facts about Rajesh's skills (see info below).



RAJESH INFO:

{info}

""",
            llm=google.beta.realtime.RealtimeModel(
                voice="Fenrir",
                temperature=1.2,
                api_key=os.getenv("GEMINI_API_KEY"),
            ),
        )

    async def on_enter(self):
        logger.info("DevRaze has entered the room!")
        self.session.generate_reply(
            instructions="Briefly greet the user, introduce yourself as DevRaze, and tell them to ask you something about Rajesh. Keep it punchy and edgy."
        )


async def entrypoint(ctx: JobContext):
    """

    Main entrypoint for the agent.

    Called when the agent joins a room.

    """
    logger.info(f"Agent joining room: {ctx.room.name}")
    
    session = AgentSession()

    await session.start(
        agent=VisionAssistant(),
        room=ctx.room,
        vad=vad.Silero(),
        room_input_options=RoomInputOptions(
            video_enabled=False,
            noise_cancellation=noise_cancellation.BVC(),
        ),
    )
    
    logger.info("Agent session started successfully - ready to roast!")


if __name__ == "__main__":
    # This allows running the agent standalone for testing
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))