IDKHowToCodeFr commited on
Commit
bd72f20
·
1 Parent(s): 90962fb

fix(api): fix HTTP 500 on reply endpoint due to kwarg mismatch and missing schema

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -110,12 +110,20 @@ async def reply(req: Dict[str, Any]):
110
  if re.search(p, msg):
111
  if turn > 2: return {"action": "end", "rationale": "Repeated auto-reply."}
112
  return {"action": "wait", "wait_seconds": 3600, "rationale": "Auto-reply wait."}
 
 
113
  for p in INTENT_PATTERNS:
114
  if re.search(p, msg):
115
- res = await compose_with_fallback(f"Merchant said: {msg}", system="Role: Vera AI. Interest detected. Provide EXACT next step action. 15 words max.")
 
 
 
116
  return {"action": "send", "body": res.get("body", "I'm setting that up for you now.") if res else "I'm setting that up now.", "cta": "Reply YES"}
117
 
118
- res = await compose_with_fallback(f"Merchant: {msg}", system="Role: Vera AI. Growth Strategist. Be concise.")
 
 
 
119
  return {"action": "send", "body": res.get("body", "Understood. Proceed?") if res else "Understood. Proceed?", "cta": "Reply YES"}
120
 
121
  if __name__ == "__main__":
 
110
  if re.search(p, msg):
111
  if turn > 2: return {"action": "end", "rationale": "Repeated auto-reply."}
112
  return {"action": "wait", "wait_seconds": 3600, "rationale": "Auto-reply wait."}
113
+ reply_schema = 'RETURN JSON FORMAT WITH keys "body", "cta", and "rationale".'
114
+
115
  for p in INTENT_PATTERNS:
116
  if re.search(p, msg):
117
+ res = await compose_with_fallback(
118
+ f"Merchant said: {msg}",
119
+ full_system=f"Role: Vera AI. Interest detected. Provide EXACT next step action. 15 words max. {reply_schema}"
120
+ )
121
  return {"action": "send", "body": res.get("body", "I'm setting that up for you now.") if res else "I'm setting that up now.", "cta": "Reply YES"}
122
 
123
+ res = await compose_with_fallback(
124
+ f"Merchant: {msg}",
125
+ full_system=f"Role: Vera AI. Growth Strategist. Be concise. {reply_schema}"
126
+ )
127
  return {"action": "send", "body": res.get("body", "Understood. Proceed?") if res else "Understood. Proceed?", "cta": "Reply YES"}
128
 
129
  if __name__ == "__main__":