File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
agent_telephony/twilio_livekit
agent_twilio/src/functions Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 55from pydantic import BaseModel
66from restack_ai .function import NonRetryableError , function
77
8+ class Message (BaseModel ):
9+ role : str
10+ content : str
811
912class LlmLogicResponse (BaseModel ):
1013 """Structured AI decision output used to interrupt conversations."""
@@ -15,7 +18,7 @@ class LlmLogicResponse(BaseModel):
1518
1619
1720class LlmLogicInput (BaseModel ):
18- messages : list [dict ]
21+ messages : list [Message ]
1922 documentation : str
2023
2124
@@ -26,6 +29,12 @@ async def llm_logic(
2629 try :
2730 client = OpenAI (api_key = os .environ .get ("OPENAI_API_KEY" ))
2831
32+ user_messages = [msg for msg in function_input .messages if msg .role == "user" ]
33+ if len (user_messages ) == 1 :
34+ voice_mail_detection = "End the call if a voice mail is detected."
35+ else :
36+ voice_mail_detection = ""
37+
2938 response = client .beta .chat .completions .parse (
3039 model = "gpt-4o" ,
3140 messages = [
@@ -35,7 +44,7 @@ async def llm_logic(
3544 "Analyze the developer's questions and determine if an interruption is needed. "
3645 "Use the Restack documentation for accurate answers. "
3746 "Track what the developer has learned and update their belief state."
38- "End the call if a voice mail is detected. "
47+ f" { voice_mail_detection } "
3948 f"Restack Documentation: { function_input .documentation } "
4049 ),
4150 },
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ async def send_metrics(
5353 )
5454 await client .send_agent_event (
5555 event_name = "pipeline_metrics" ,
56- agent_id = agent_id . replace ( "local-" , "" ) ,
56+ agent_id = agent_id ,
5757 run_id = run_id ,
5858 event_input = {
5959 "metrics" : pipeline_metrics ,
You can’t perform that action at this time.
0 commit comments