gpt-engineer-app[bot] commited on
Commit
9bb3b7a
Β·
1 Parent(s): 68809c8
Files changed (1) hide show
  1. src/server/forensic.functions.ts +9 -14
src/server/forensic.functions.ts CHANGED
@@ -2,7 +2,7 @@ import { createServerFn } from "@tanstack/react-start";
2
  import { z } from "zod";
3
  import { sanitize, restore } from "./branch-debug.functions";
4
  import { requireSupabaseAuth } from "@/integrations/supabase/auth-middleware";
5
- import { aiAuthHeaders, aiChatCompletionsUrl, getAIConfig, resolveModel } from "./ai-config";
6
 
7
  // ───────────────────────── SSRF Guard ─────────────────────────
8
  // Reject loopback, private (RFC1918), link-local, and cloud metadata addresses
@@ -497,19 +497,14 @@ export const runForensicStage = createServerFn({ method: "POST" })
497
  if (logsS) userParts.push(`\n\nSYSTEM LOGS (anonymized):\n${logsS.sanitized.slice(0, 40_000)}`);
498
  if (bagS) userParts.push(`\n\nROS BAG / SENSOR DATA (anonymized):\n${bagS.sanitized.slice(0, 40_000)}`);
499
 
500
- const resp = await fetch(aiChatCompletionsUrl(), {
501
- method: "POST",
502
- headers: aiAuthHeaders(),
503
- body: JSON.stringify({
504
- model: resolveModel("google/gemini-2.5-flash"),
505
- messages: [
506
- { role: "system", content: STAGE_PROMPTS[data.stage] },
507
- { role: "user", content: userParts.join("") },
508
- ],
509
- tools,
510
- tool_choice: { type: "function", function: { name: toolName } },
511
- }),
512
- });
513
 
514
  if (!resp.ok) {
515
  const text = await resp.text();
 
2
  import { z } from "zod";
3
  import { sanitize, restore } from "./branch-debug.functions";
4
  import { requireSupabaseAuth } from "@/integrations/supabase/auth-middleware";
5
+ import { fetchAIWithFallback, getAIConfig } from "./ai-config";
6
 
7
  // ───────────────────────── SSRF Guard ─────────────────────────
8
  // Reject loopback, private (RFC1918), link-local, and cloud metadata addresses
 
497
  if (logsS) userParts.push(`\n\nSYSTEM LOGS (anonymized):\n${logsS.sanitized.slice(0, 40_000)}`);
498
  if (bagS) userParts.push(`\n\nROS BAG / SENSOR DATA (anonymized):\n${bagS.sanitized.slice(0, 40_000)}`);
499
 
500
+ const resp = await fetchAIWithFallback(JSON.stringify({
501
+ messages: [
502
+ { role: "system", content: STAGE_PROMPTS[data.stage] },
503
+ { role: "user", content: userParts.join("") },
504
+ ],
505
+ tools,
506
+ tool_choice: { type: "function", function: { name: toolName } },
507
+ }), "google/gemini-2.5-flash", `forensicStage${data.stage}`);
 
 
 
 
 
508
 
509
  if (!resp.ok) {
510
  const text = await resp.text();