File tree 2 files changed +12
-3
lines changed
agent_telephony/twilio_livekit
agent_twilio/src/functions
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 5
5
from pydantic import BaseModel
6
6
from restack_ai .function import NonRetryableError , function
7
7
8
+ class Message (BaseModel ):
9
+ role : str
10
+ content : str
8
11
9
12
class LlmLogicResponse (BaseModel ):
10
13
"""Structured AI decision output used to interrupt conversations."""
@@ -15,7 +18,7 @@ class LlmLogicResponse(BaseModel):
15
18
16
19
17
20
class LlmLogicInput (BaseModel ):
18
- messages : list [dict ]
21
+ messages : list [Message ]
19
22
documentation : str
20
23
21
24
@@ -26,6 +29,12 @@ async def llm_logic(
26
29
try :
27
30
client = OpenAI (api_key = os .environ .get ("OPENAI_API_KEY" ))
28
31
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
+
29
38
response = client .beta .chat .completions .parse (
30
39
model = "gpt-4o" ,
31
40
messages = [
@@ -35,7 +44,7 @@ async def llm_logic(
35
44
"Analyze the developer's questions and determine if an interruption is needed. "
36
45
"Use the Restack documentation for accurate answers. "
37
46
"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 } "
39
48
f"Restack Documentation: { function_input .documentation } "
40
49
),
41
50
},
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ async def send_metrics(
53
53
)
54
54
await client .send_agent_event (
55
55
event_name = "pipeline_metrics" ,
56
- agent_id = agent_id . replace ( "local-" , "" ) ,
56
+ agent_id = agent_id ,
57
57
run_id = run_id ,
58
58
event_input = {
59
59
"metrics" : pipeline_metrics ,
You can’t perform that action at this time.
0 commit comments