30 lines
803 B
TypeScript
30 lines
803 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { runSiteMenteVoiceTurn } from "../../../../lib/ai/siteMenteAgent";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const body = (await request.json()) as { transcript?: string };
|
|
|
|
if (!body.transcript || typeof body.transcript !== "string") {
|
|
return NextResponse.json(
|
|
{ error: "transcript is required." },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
const response = await runSiteMenteVoiceTurn({
|
|
transcript: body.transcript,
|
|
});
|
|
|
|
return NextResponse.json(response);
|
|
} catch (error) {
|
|
console.error("[SiteMente][API] Voice route failed", error);
|
|
return NextResponse.json(
|
|
{ error: "Failed to generate voice response." },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|