Skip to content

Commit ec8bab1

Browse files
committed
fix voice mail
1 parent a7567b6 commit ec8bab1

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

agent_telephony/twilio_livekit/agent_twilio/src/functions/llm_logic.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from pydantic import BaseModel
66
from restack_ai.function import NonRetryableError, function
77

8+
class Message(BaseModel):
9+
role: str
10+
content: str
811

912
class LlmLogicResponse(BaseModel):
1013
"""Structured AI decision output used to interrupt conversations."""
@@ -15,7 +18,7 @@ class LlmLogicResponse(BaseModel):
1518

1619

1720
class 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
},

agent_telephony/twilio_livekit/livekit_pipeline/src/metrics.py

+1-1
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)