This commit is contained in:
Ben Cherry
2025-07-10 17:26:30 -07:00
parent b8eabc59ac
commit 2420b92dc7
2 changed files with 25 additions and 3 deletions
+17
View File
@@ -1,3 +1,4 @@
import asyncio
import logging
from dotenv import load_dotenv
@@ -12,6 +13,7 @@ from livekit.agents import (
WorkerOptions,
cli,
metrics,
workflows,
)
from livekit.agents.llm import function_tool
from livekit.agents.voice import MetricsCollectedEvent
@@ -48,6 +50,21 @@ class Assistant(Agent):
return "sunny with a temperature of 70 degrees."
@function_tool
async def send_email(self, context: RunContext, subject: str, body: str):
"""Use this tool to send an email on behalf of the user.
Args:
subject: The subject of the email
body: The body of the email
"""
email_result = await workflows.GetEmailAgent(chat_ctx=self.chat_ctx)
send_to_email_address = email_result.email_address
await asyncio.sleep(1) # simulate sending the email
return "Email sent to " + send_to_email_address
def prewarm(proc: JobProcess):
proc.userdata["vad"] = silero.VAD.load()