debug(gemini): add /api/chat/debug endpoint to capture raw response

This commit is contained in:
2026-06-01 13:51:46 -07:00
parent 42c46d0f88
commit fbb542a3c7
2 changed files with 22 additions and 0 deletions

View 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."
});
}

View File

@@ -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[] = [];