Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -64,11 +64,23 @@ def generate_answer_with_groq(question, context, retries=3, delay=2):
|
|
64 |
"Authorization": f"Bearer {api_key}",
|
65 |
"Content-Type": "application/json",
|
66 |
}
|
67 |
-
prompt =
|
|
|
|
|
|
|
|
|
68 |
payload = {
|
69 |
"model": "llama3-8b-8192",
|
70 |
"messages": [
|
71 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
{"role": "user", "content": prompt},
|
73 |
],
|
74 |
"temperature": 0.5,
|
@@ -87,6 +99,7 @@ def generate_answer_with_groq(question, context, retries=3, delay=2):
|
|
87 |
else:
|
88 |
return f"⚠️ Groq API Error: {str(e)}"
|
89 |
|
|
|
90 |
# --- Twilio Chat Handlers ---
|
91 |
def fetch_latest_incoming_message(account_sid, auth_token, conversation_sid):
|
92 |
client = Client(account_sid, auth_token)
|
|
|
64 |
"Authorization": f"Bearer {api_key}",
|
65 |
"Content-Type": "application/json",
|
66 |
}
|
67 |
+
prompt = (
|
68 |
+
f"Customer asked: '{question}'\n\n"
|
69 |
+
f"Here is the relevant product or policy info to help:\n{context}\n\n"
|
70 |
+
f"Respond in a friendly and helpful tone as a toy shop support agent."
|
71 |
+
)
|
72 |
payload = {
|
73 |
"model": "llama3-8b-8192",
|
74 |
"messages": [
|
75 |
+
{
|
76 |
+
"role": "system",
|
77 |
+
"content": (
|
78 |
+
"You are ToyBot, a friendly and helpful WhatsApp assistant for an online toy shop. "
|
79 |
+
"Your goal is to politely answer customer questions, help them choose the right toys, "
|
80 |
+
"provide order or delivery information, explain return policies, and guide them through purchases. "
|
81 |
+
"Always sound warm, helpful, and trustworthy like a professional customer support agent."
|
82 |
+
)
|
83 |
+
},
|
84 |
{"role": "user", "content": prompt},
|
85 |
],
|
86 |
"temperature": 0.5,
|
|
|
99 |
else:
|
100 |
return f"⚠️ Groq API Error: {str(e)}"
|
101 |
|
102 |
+
|
103 |
# --- Twilio Chat Handlers ---
|
104 |
def fetch_latest_incoming_message(account_sid, auth_token, conversation_sid):
|
105 |
client = Client(account_sid, auth_token)
|