fix: restore AI Assist to use modelAdapter directly

- Removed intermediate /api/ai-assist call that caused 404 with basePath
- AI Assist now calls modelAdapter.generateAIAssistStream directly
- This fixes the HTTP 404 error on the live site
This commit is contained in:
Gemini AI
2025-12-29 00:32:35 +04:00
Unverified
parent 42570a14b7
commit ac2ba44fbc

View File

@@ -18,7 +18,6 @@ import { Input } from "@/components/ui/input";
import useStore from "@/lib/store";
import { translations } from "@/lib/i18n/translations";
import modelAdapter from "@/lib/services/adapter-instance";
import { safeJsonFetch } from "@/lib/safeJsonFetch";
// --- Types ---
@@ -346,42 +345,12 @@ export default function AIAssist() {
setAIAssistHistory(prev => [...prev, assistantMsg]);
try {
// First, get the plan orchestrator prompt from our new API
type AiAssistApiResponse = {
prompt?: string;
step?: string;
requestId?: string;
success?: boolean;
error?: string;
};
const apiResult = await safeJsonFetch<AiAssistApiResponse>("/api/ai-assist", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
request: finalInput,
step: assistStep === "plan" ? "generate" : "plan",
plan: aiPlan
}),
});
if (!apiResult.ok) {
console.error("AI Assist API failed:", apiResult.error);
throw new Error(apiResult.error.message);
}
if (apiResult.data.error) {
throw new Error(apiResult.data.error);
}
const prompt = apiResult.data.prompt ?? "";
let accumulated = "";
let lastParsedPreview: PreviewData | null = null;
const response = await modelAdapter.generateAIAssistStream(
{
messages: [...aiAssistHistory, { role: "system", content: prompt } as any],
messages: [...aiAssistHistory, { role: "user" as const, content: finalInput, timestamp: new Date() }],
currentAgent,
onChunk: (chunk) => {
accumulated += chunk;