feat(mission-control): restore MC tabs - temple, office, memory, claude, pdf-viewer, resume, resume-upload, temple-3d, demos
Also added: - Memory API endpoints - Briefs API endpoints - AnveVoice stats API - Claude spawn API - TTS proxy - Cleopatra voice widget - api-auth middleware
This commit is contained in:
+34
-17
@@ -1,35 +1,52 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const MINIMAX_API_KEY = process.env.MINIMAX_API_KEY || "sk-cp-aRrwyWpeY7iheh18JiqLNHkaz0Kude0MRYFt2w5fDzk-5026VI-HtO06_us_DQjJ8yHt4Qevgz-UE3F566cnjYDZPMSUGLLFgjUpwOiV0Ir0hTbeUclMeIQ";
|
||||
const MINIMAX_URL = "https://api.minimax.io/v1/text/chatcompletion_v2";
|
||||
|
||||
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.
|
||||
// Cleopatra personality - short, friendly, Spanish
|
||||
const systemPrompt = `Eres Cleopatra, una agente de ventas profesional hispanohablante.
|
||||
Respuestas CORTAS (1-2 oraciones), amigables, en español.
|
||||
Siempre suena interesada y servicial.
|
||||
Si no entiendes algo, pide que repitan por favor.`;
|
||||
|
||||
User: ${text}
|
||||
const messages = [
|
||||
{ role: "system", content: systemPrompt },
|
||||
{ role: "user", content: text }
|
||||
];
|
||||
|
||||
Response in Spanish:`;
|
||||
|
||||
const res = await fetch("http://127.0.0.1:11434/api/generate", {
|
||||
const res = await fetch(MINIMAX_URL, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
signal: AbortSignal.timeout(60000),
|
||||
headers: {
|
||||
"Authorization": `Bearer ${MINIMAX_API_KEY}`,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: "phi3:mini",
|
||||
prompt: prompt,
|
||||
stream: false
|
||||
model: "MiniMax-M2.7",
|
||||
messages,
|
||||
temperature: 0.8,
|
||||
max_tokens: 150
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error("MiniMax API error");
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
const reply = (data.response || "¡Hola! Estoy aquí.").substring(0, 200);
|
||||
|
||||
return NextResponse.json({ response: reply });
|
||||
const reply = data.choices?.[0]?.message?.content?.trim() ||
|
||||
"¡Estoy aquí para ayudarte! ¿Qué necesitas?";
|
||||
|
||||
return NextResponse.json({ response: reply.substring(0, 300) });
|
||||
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
console.error("Chat error:", e);
|
||||
return NextResponse.json({
|
||||
response: "Tengo problemas para conectar. Intenta de nuevo."
|
||||
}, { status: 500 });
|
||||
response: "Tengo problemas para conectar. ¿Puedes intentar de nuevo?"
|
||||
}, { status: 200 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user