Clean up: Remove all old widgets, keep only V2 (disabled by default)
This commit is contained in:
@@ -1,98 +0,0 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
// MiniMax API configuration
|
||||
const MINIMAX_API_KEY = process.env.MINIMAX_API_KEY || "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJTaXRlTWVudGUiLCJyb2xlIjoiYW5vbiIsImlhdCI6MTczODcxMjAwMCwiZXhwIjoyMDU0MzcyMDAwfQ.VxYNdTUkG4N0K2T8K3pK4JzY3vN8X9vK2pK3JzY2vN8X9";
|
||||
const MINIMAX_BASE_URL = "https://api.minimax.chat/v1";
|
||||
|
||||
interface Message {
|
||||
role: "user" | "assistant";
|
||||
content: string;
|
||||
}
|
||||
|
||||
interface RequestBody {
|
||||
message: string;
|
||||
language: "es" | "en";
|
||||
businessType: string;
|
||||
businessName: string;
|
||||
history?: Message[];
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body: RequestBody = await request.json();
|
||||
const { message, language, businessType, businessName, history = [] } = body;
|
||||
|
||||
// Build conversation context
|
||||
const systemPrompt = `You are a friendly AI assistant for ${businessName}, a ${businessType} business.
|
||||
|
||||
IMPORTANT RULES:
|
||||
- Always respond in the SAME language the user uses
|
||||
- Default to Spanish (respond in Spanish unless user clearly speaks English)
|
||||
- Keep responses SHORT: 1-3 sentences max
|
||||
- Be helpful, friendly, and professional
|
||||
- If asked about pricing, mention: €299-€1,950/month depending on plan
|
||||
- If asked about booking, say you'll help them book
|
||||
- Never make up specific prices or details you don't know
|
||||
|
||||
Current language mode: ${language}`;
|
||||
|
||||
// Build messages array
|
||||
const messages: Message[] = [
|
||||
{ role: "assistant", content: systemPrompt }
|
||||
];
|
||||
|
||||
// Add history (last 5 messages for context)
|
||||
if (history.length > 0) {
|
||||
messages.push(...history.slice(-5));
|
||||
}
|
||||
|
||||
// Add current message
|
||||
messages.push({ role: "user", content: message });
|
||||
|
||||
// Call MiniMax API
|
||||
const response = await fetch(`${MINIMAX_BASE_URL}/text/chatcompletion_v2`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Authorization": `Bearer ${MINIMAX_API_KEY}`,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: "MiniMax-M2.5",
|
||||
messages,
|
||||
temperature: 0.7,
|
||||
max_tokens: 500
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.text();
|
||||
console.error("MiniMax API error:", error);
|
||||
|
||||
// Fallback response
|
||||
const fallbackResponse = language === "es"
|
||||
? "Lo siento, tuve un problema técnico. ¿Puedes repetir tu pregunta?"
|
||||
: "Sorry, I had a technical issue. Can you repeat your question?";
|
||||
|
||||
return NextResponse.json({ response: fallbackResponse });
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const aiResponse = data.choices?.[0]?.message?.content ||
|
||||
data.reply ||
|
||||
(language === "es"
|
||||
? "Gracias por tu mensaje. ¿En qué más puedo ayudarte?"
|
||||
: "Thanks for your message. How else can I help you?");
|
||||
|
||||
return NextResponse.json({ response: aiResponse });
|
||||
|
||||
} catch (error) {
|
||||
console.error("Voice chat API error:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Internal server error" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable body parsing for streaming if needed
|
||||
export const runtime = "nodejs";
|
||||
+4
-2
@@ -8,7 +8,8 @@ import HeroSlider, {
|
||||
import JsonLdSchemas from "../components/site-mente/JsonLdSchemas";
|
||||
import ServicesAndPricing from "../components/site-mente/ServicesAndPricing";
|
||||
import SeoMeta from "../components/site-mente/SeoMeta";
|
||||
import SiteMenteVoiceWidget from "../components/SiteMenteVoiceWidget";
|
||||
// Old widget disabled - using V2 only
|
||||
// import SiteMenteVoiceWidget from "../components/SiteMenteVoiceWidget";
|
||||
|
||||
const fadeUp = {
|
||||
hidden: { opacity: 0, y: 24 },
|
||||
@@ -781,7 +782,8 @@ export default function HomePage() {
|
||||
<div className="font-sans text-white bg-[#5e4a8a]">
|
||||
<SeoMeta lang={lang} />
|
||||
<JsonLdSchemas lang={lang} />
|
||||
<SiteMenteVoiceWidget initialLang={lang} />
|
||||
{/* Old widget disabled - V2 coming soon */}
|
||||
{/* <SiteMenteVoiceWidget initialLang={lang} /> */}
|
||||
<header className="relative overflow-hidden">
|
||||
<nav className="relative z-10 border-b border-white/10 bg-[#5e4a8a]/90 backdrop-blur">
|
||||
<div className="mx-auto flex w-full max-w-6xl items-center justify-between px-6 py-4">
|
||||
|
||||
Reference in New Issue
Block a user