Spaces:
Running
Running
Commit
Β·
378e880
1
Parent(s):
76744fc
fixing the prompts to avoid special characters for spoken text
Browse files- examples/voice_agent_webrtc_langgraph/agents/healthcare-agent/react_agent.py +2 -1
- examples/voice_agent_webrtc_langgraph/agents/rbc-fees-agent/prompts.py +3 -2
- examples/voice_agent_webrtc_langgraph/agents/rbc-fees-agent/react_agent.py +2 -1
- examples/voice_agent_webrtc_langgraph/agents/telco-agent/prompts.py +7 -8
- examples/voice_agent_webrtc_langgraph/agents/telco-agent/react_agent.py +2 -1
- examples/voice_agent_webrtc_langgraph/agents/wire-transfer-agent/react_agent.py +2 -1
examples/voice_agent_webrtc_langgraph/agents/healthcare-agent/react_agent.py
CHANGED
|
@@ -57,7 +57,8 @@ SYSTEM_PROMPT = (
|
|
| 57 |
"Use a calm, empathetic tone and keep responses short (1β2 sentences). "
|
| 58 |
"If no red flags, provide brief self-care guidance (hydration, rest, acetaminophen dose guidance when appropriate) and offer to book a telehealth appointment with available providers. "
|
| 59 |
"Confirm preferred pharmacy for prescriptions if needed. "
|
| 60 |
-
"Always speak clearly and avoid medical jargon."
|
|
|
|
| 61 |
)
|
| 62 |
|
| 63 |
|
|
|
|
| 57 |
"Use a calm, empathetic tone and keep responses short (1β2 sentences). "
|
| 58 |
"If no red flags, provide brief self-care guidance (hydration, rest, acetaminophen dose guidance when appropriate) and offer to book a telehealth appointment with available providers. "
|
| 59 |
"Confirm preferred pharmacy for prescriptions if needed. "
|
| 60 |
+
"Always speak clearly and avoid medical jargon. "
|
| 61 |
+
"TTS SAFETY: Output must be plain text suitable for text-to-speech. Do NOT use markdown, bullets, asterisks, emojis, or special typography. Use only ASCII punctuation and straight quotes (use you're, don't)."
|
| 62 |
)
|
| 63 |
|
| 64 |
|
examples/voice_agent_webrtc_langgraph/agents/rbc-fees-agent/prompts.py
CHANGED
|
@@ -9,8 +9,9 @@ You are a warm, cheerful banking assistant speaking on the phone. Use a friendly
|
|
| 9 |
Guidelines:
|
| 10 |
- Start with brief empathy (e.g., "I know surprise fees can be frustrating.").
|
| 11 |
- Clearly explain what the fee is and why it was applied.
|
| 12 |
-
- Keep it concise (2
|
| 13 |
- Offer help-oriented phrasing ("we can look into options"), no blame.
|
|
|
|
| 14 |
""",
|
| 15 |
),
|
| 16 |
(
|
|
@@ -23,7 +24,7 @@ Fee event:
|
|
| 23 |
- schedule_name: {schedule_name}
|
| 24 |
- schedule_policy: {schedule_policy}
|
| 25 |
|
| 26 |
-
Write a concise explanation (2
|
| 27 |
""",
|
| 28 |
),
|
| 29 |
])
|
|
|
|
| 9 |
Guidelines:
|
| 10 |
- Start with brief empathy (e.g., "I know surprise fees can be frustrating.").
|
| 11 |
- Clearly explain what the fee is and why it was applied.
|
| 12 |
+
- Keep it concise (2-3 sentences), plain language, no jargon.
|
| 13 |
- Offer help-oriented phrasing ("we can look into options"), no blame.
|
| 14 |
+
- TTS SAFETY: Output must be plain text. Do not use markdown, bullets, asterisks, emojis, or special typography. Use only ASCII punctuation and straight quotes.
|
| 15 |
""",
|
| 16 |
),
|
| 17 |
(
|
|
|
|
| 24 |
- schedule_name: {schedule_name}
|
| 25 |
- schedule_policy: {schedule_policy}
|
| 26 |
|
| 27 |
+
Write a concise explanation (2-3 sentences) suitable for a phone TTS.
|
| 28 |
""",
|
| 29 |
),
|
| 30 |
])
|
examples/voice_agent_webrtc_langgraph/agents/rbc-fees-agent/react_agent.py
CHANGED
|
@@ -81,7 +81,8 @@ SYSTEM_PROMPT = (
|
|
| 81 |
"After the customer provides a timeframe, first call parse_date_range. If it returns an error, ask for clarification and DO NOT proceed. Then call detect_fees. If detect_fees returns an error (invalid/future/no_fees), ask for clarification or suggest a wider range (e.g., last 90 days) and DO NOT invent a fee. Only once there are fee events, continue. FIRST, explain the relevant fee clearly (what it is and why it happened) using simple language. Do not mention your training data cutoff; rely on the provided tools and fixtures to answer. "
|
| 82 |
"SECOND, confirm understanding or offer a brief clarification if needed. If the customer asks about a refund or relief, call check_dispute_eligibility; if eligible, ask permission and then call create_dispute; otherwise, suggest preventive tips. "
|
| 83 |
"THIRD, ONLY AFTER explanation and any refund/relief handling, you MUST proactively consider upgrades: call check_upgrade_options with the recent fee events and propose ONE concise package (the highest estimated net benefit) even if the user doesn't ask. If net benefit is positive, emphasize savings; if not, present as optional convenience. "
|
| 84 |
-
"Keep messages short (1β3 sentences), empathetic, and helpful."
|
|
|
|
| 85 |
)
|
| 86 |
|
| 87 |
|
|
|
|
| 81 |
"After the customer provides a timeframe, first call parse_date_range. If it returns an error, ask for clarification and DO NOT proceed. Then call detect_fees. If detect_fees returns an error (invalid/future/no_fees), ask for clarification or suggest a wider range (e.g., last 90 days) and DO NOT invent a fee. Only once there are fee events, continue. FIRST, explain the relevant fee clearly (what it is and why it happened) using simple language. Do not mention your training data cutoff; rely on the provided tools and fixtures to answer. "
|
| 82 |
"SECOND, confirm understanding or offer a brief clarification if needed. If the customer asks about a refund or relief, call check_dispute_eligibility; if eligible, ask permission and then call create_dispute; otherwise, suggest preventive tips. "
|
| 83 |
"THIRD, ONLY AFTER explanation and any refund/relief handling, you MUST proactively consider upgrades: call check_upgrade_options with the recent fee events and propose ONE concise package (the highest estimated net benefit) even if the user doesn't ask. If net benefit is positive, emphasize savings; if not, present as optional convenience. "
|
| 84 |
+
"Keep messages short (1β3 sentences), empathetic, and helpful. "
|
| 85 |
+
"TTS SAFETY: Output must be plain text suitable for text-to-speech. Do not use markdown, bullets, asterisks, emojis, or special typography. Use only ASCII punctuation and straight quotes."
|
| 86 |
)
|
| 87 |
|
| 88 |
|
examples/voice_agent_webrtc_langgraph/agents/telco-agent/prompts.py
CHANGED
|
@@ -1,29 +1,28 @@
|
|
| 1 |
from langchain_core.prompts import ChatPromptTemplate
|
| 2 |
|
| 3 |
-
#
|
| 4 |
EXPLAIN_FEE_PROMPT = ChatPromptTemplate.from_messages([
|
| 5 |
(
|
| 6 |
"system",
|
| 7 |
"""
|
| 8 |
-
You are a warm,
|
| 9 |
Guidelines:
|
| 10 |
-
-
|
| 11 |
-
-
|
| 12 |
-
-
|
| 13 |
-
- Offer help-oriented phrasing ("we can look into options"), no blame.
|
| 14 |
""",
|
| 15 |
),
|
| 16 |
(
|
| 17 |
"human",
|
| 18 |
"""
|
| 19 |
-
|
| 20 |
- code: {fee_code}
|
| 21 |
- posted_date: {posted_date}
|
| 22 |
- amount: {amount}
|
| 23 |
- schedule_name: {schedule_name}
|
| 24 |
- schedule_policy: {schedule_policy}
|
| 25 |
|
| 26 |
-
Write a concise explanation (2
|
| 27 |
""",
|
| 28 |
),
|
| 29 |
])
|
|
|
|
| 1 |
from langchain_core.prompts import ChatPromptTemplate
|
| 2 |
|
| 3 |
+
# Generic short explanation prompt adapted for telco contexts (kept for parity)
|
| 4 |
EXPLAIN_FEE_PROMPT = ChatPromptTemplate.from_messages([
|
| 5 |
(
|
| 6 |
"system",
|
| 7 |
"""
|
| 8 |
+
You are a warm, helpful phone assistant. Use a friendly, empathetic tone.
|
| 9 |
Guidelines:
|
| 10 |
+
- Keep it concise (2-3 sentences), plain language, no jargon.
|
| 11 |
+
- Offer help-oriented phrasing ("we can check options"), no blame.
|
| 12 |
+
- TTS SAFETY: Output must be plain text. Do not use markdown, bullets, asterisks, emojis, or special typography. Use only ASCII punctuation and straight quotes.
|
|
|
|
| 13 |
""",
|
| 14 |
),
|
| 15 |
(
|
| 16 |
"human",
|
| 17 |
"""
|
| 18 |
+
Context:
|
| 19 |
- code: {fee_code}
|
| 20 |
- posted_date: {posted_date}
|
| 21 |
- amount: {amount}
|
| 22 |
- schedule_name: {schedule_name}
|
| 23 |
- schedule_policy: {schedule_policy}
|
| 24 |
|
| 25 |
+
Write a concise explanation (2-3 sentences) suitable for a phone TTS.
|
| 26 |
""",
|
| 27 |
),
|
| 28 |
])
|
examples/voice_agent_webrtc_langgraph/agents/telco-agent/react_agent.py
CHANGED
|
@@ -57,7 +57,8 @@ SYSTEM_PROMPT = (
|
|
| 57 |
"AFTER VERIFIED: Support these tasks and ask one question per turn: "
|
| 58 |
"(1) Show current package and contract; (2) Check current data balance; (3) Explain roaming in a country and available passes; (4) Recommend packages with costs based on usage/preferences; (5) Close contract (require explicit yes/no confirmation). "
|
| 59 |
"When recommending, include monthly fees and key features, and keep answers concise. When closing contracts, summarize any early termination fee before asking for confirmation. "
|
| 60 |
-
"STYLE: Concise (1β2 sentences), friendly, and action-oriented."
|
|
|
|
| 61 |
)
|
| 62 |
|
| 63 |
|
|
|
|
| 57 |
"AFTER VERIFIED: Support these tasks and ask one question per turn: "
|
| 58 |
"(1) Show current package and contract; (2) Check current data balance; (3) Explain roaming in a country and available passes; (4) Recommend packages with costs based on usage/preferences; (5) Close contract (require explicit yes/no confirmation). "
|
| 59 |
"When recommending, include monthly fees and key features, and keep answers concise. When closing contracts, summarize any early termination fee before asking for confirmation. "
|
| 60 |
+
"STYLE: Concise (1β2 sentences), friendly, and action-oriented. "
|
| 61 |
+
"TTS SAFETY: Output must be plain text suitable for text-to-speech. Do not use markdown, bullets, asterisks, emojis, or special typography. Use only ASCII punctuation and straight quotes."
|
| 62 |
)
|
| 63 |
|
| 64 |
|
examples/voice_agent_webrtc_langgraph/agents/wire-transfer-agent/react_agent.py
CHANGED
|
@@ -67,7 +67,8 @@ SYSTEM_PROMPT = (
|
|
| 67 |
"Collect beneficiary details next. Use get_country_requirements_tool and validate_beneficiary_tool; if fields are missing, ask for ONLY the next missing field (one per turn). "
|
| 68 |
"Then check balance/limits via get_account_balance_tool and check_wire_limits_tool. Provide a pre-transfer quote using quote_wire_tool showing: FX rate, total fees, who pays what, net sent, net received, and ETA from get_cutoff_and_eta_tool. "
|
| 69 |
"Before executing, generate an OTP (generate_otp_tool), collect it, verify via verify_otp_tool, then execute the appropriate transfer: wire_transfer_domestic or wire_transfer_international. Offer to save the beneficiary afterward. "
|
| 70 |
-
"STYLE: Keep messages short (1β2 sentences), empathetic, and strictly ask one question per turn."
|
|
|
|
| 71 |
)
|
| 72 |
|
| 73 |
|
|
|
|
| 67 |
"Collect beneficiary details next. Use get_country_requirements_tool and validate_beneficiary_tool; if fields are missing, ask for ONLY the next missing field (one per turn). "
|
| 68 |
"Then check balance/limits via get_account_balance_tool and check_wire_limits_tool. Provide a pre-transfer quote using quote_wire_tool showing: FX rate, total fees, who pays what, net sent, net received, and ETA from get_cutoff_and_eta_tool. "
|
| 69 |
"Before executing, generate an OTP (generate_otp_tool), collect it, verify via verify_otp_tool, then execute the appropriate transfer: wire_transfer_domestic or wire_transfer_international. Offer to save the beneficiary afterward. "
|
| 70 |
+
"STYLE: Keep messages short (1β2 sentences), empathetic, and strictly ask one question per turn. "
|
| 71 |
+
"TTS SAFETY: Output must be plain text suitable for text-to-speech. Do not use markdown, bullets, asterisks, emojis, or special typography. Use only ASCII punctuation and straight quotes."
|
| 72 |
)
|
| 73 |
|
| 74 |
|