fix(support-chat): send classifier-compatible payload
Deploy Canina / deploy (push) Successful in 1m54s

This commit is contained in:
devops committed 2026-10-15 18:51:10 +00:00
1 parent 18e59efdcc
commit c16e34df02
1 file changed
+1 -1
@@ -64,7 +64,7 @@ export class SupportChatService {
let intent: 'public' | 'orders' | 'wallet';
try {
if (!url || !key || !url.endsWith('/ask')) throw new Error('disabled');
const response = await fetch(url.replace(/\/ask$/, '/classify'), { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(45000), body: JSON.stringify({ message: input.message, conversation_history: conversationHistory, page_context: pageContext, selection }) });
const response = await fetch(url.replace(/\/ask$/, '/classify'), { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${key}` }, signal: AbortSignal.timeout(45000), body: JSON.stringify({ message: input.message, conversation_history: conversationHistory, selection }) });
if (response.status === 400) return { answer: 'فقط درباره محصولات و سلامت حیوانات خانگی و خدمات کنینا پاسخ می‌دهم.' };
if (!response.ok) throw new Error('upstream'); const data = await response.json();
if (!data || Object.keys(data).length !== 1 || !['public','orders','wallet'].includes(data.intent)) throw new Error('intent'); intent = data.intent;