debug(gemini): add /api/chat/debug endpoint to capture raw response
This commit is contained in:
14
vibn-frontend/app/api/chat/debug/route.ts
Normal file
14
vibn-frontend/app/api/chat/debug/route.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
// Global variable to store the last raw Gemini response for easy debugging
|
||||
let lastGeminiResponse: any = null;
|
||||
|
||||
export function setLastGeminiResponse(resp: any) {
|
||||
lastGeminiResponse = resp;
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json({
|
||||
lastResponse: lastGeminiResponse || "No requests captured yet since last deploy. Send a message from the desktop first."
|
||||
});
|
||||
}
|
||||
@@ -138,6 +138,14 @@ export async function callGeminiChat(opts: {
|
||||
JSON.stringify(response, null, 2),
|
||||
);
|
||||
|
||||
try {
|
||||
const { setLastGeminiResponse } =
|
||||
await import("../../app/api/chat/debug/route");
|
||||
setLastGeminiResponse(response);
|
||||
} catch (e) {
|
||||
console.warn("Failed to set debug response:", e);
|
||||
}
|
||||
|
||||
let text = "";
|
||||
let thoughts = "";
|
||||
const toolCalls: ToolCall[] = [];
|
||||
|
||||
Reference in New Issue
Block a user