d5575b58e3
Features: - Mission Control dashboard - HP Submissions tracking - AI Agents integration - Lead management CRM - Marketing email templates - Chrome extension support Tech: Next.js, TypeScript, Tailwind CSS, MySQL
36 lines
1008 B
TypeScript
36 lines
1008 B
TypeScript
import { NextResponse } from 'next/server';
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const body = await request.json();
|
|
const { text } = body;
|
|
|
|
const prompt = `You are Cleopatra, a professional Spanish-speaking sales agent. Keep responses SHORT (1-2 sentences), friendly, in Spanish.
|
|
|
|
User: ${text}
|
|
|
|
Response in Spanish:`;
|
|
|
|
const res = await fetch("http://127.0.0.1:11434/api/generate", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
signal: AbortSignal.timeout(60000),
|
|
body: JSON.stringify({
|
|
model: "phi3:mini",
|
|
prompt: prompt,
|
|
stream: false
|
|
})
|
|
});
|
|
|
|
const data = await res.json();
|
|
const reply = (data.response || "¡Hola! Estoy aquí.").substring(0, 200);
|
|
|
|
return NextResponse.json({ response: reply });
|
|
} catch (e) {
|
|
console.error(e);
|
|
return NextResponse.json({
|
|
response: "Tengo problemas para conectar. Intenta de nuevo."
|
|
}, { status: 500 });
|
|
}
|
|
}
|