UNPKG

skailan-conversations

Version:

Servicio de conversaciones y mensajería para Skailan

25 lines 1.09 kB
import axios from 'axios'; export class DetectIntentWithAI { async execute(request) { const { organizationId, text, promptName, llmConfigName } = request; const AI_SERVICE_URL = process.env.AI_SERVICE_URL || 'http://localhost:3010'; try { const response = await axios.post(`${AI_SERVICE_URL}/ai/process-text`, { text, promptName, llmConfigName, parameters: {}, }, { headers: { 'x-tenant-id': organizationId }, }); // Assuming the AI service returns a JSON string that needs to be parsed const result = JSON.parse(response.data.result); return { intent: result.intent, confidence: result.confidence }; } catch (error) { console.error('Error detecting intent with AI service:', error.response?.data || error.message); throw new Error(`Failed to detect intent: ${error.response?.data?.error || error.message}`); } } } //# sourceMappingURL=DetectIntentWithAI.js.map