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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user