feat(agent): refresh assistant model catalog

This commit is contained in:
ginnoir
2026-07-08 19:37:17 -05:00
parent 4dc04b21d6
commit b279f16ba0
6 changed files with 111 additions and 41 deletions
+17 -8
View File
@@ -3,15 +3,22 @@ import { resolveApiAuth } from "@/lib/api-auth";
import { getAssistantPreferences } from "@/lib/assistant-preference";
import { listLlmModels, resolveAssistantModel } from "@/lib/llm/models";
export const dynamic = "force-dynamic";
function noStore(response: Response): Response {
response.headers.set("Cache-Control", "no-store");
return response;
}
export async function GET(request: Request) {
const auth = await resolveApiAuth(request);
if (!auth?.userId) {
return apiError("Unauthorized", 401);
return noStore(apiError("Unauthorized", 401));
}
const assistant = await getAssistantPreferences(auth.userId);
if (!assistant.enabled) {
return apiError("Assistant not enabled", 403);
return noStore(apiError("Assistant not enabled", 403));
}
const modelList = await listLlmModels();
@@ -22,10 +29,12 @@ export async function GET(request: Request) {
models: modelList.models,
});
return apiJson({
models: modelList.models,
selectedModel: resolved.model,
fallbackModel: modelList.fallbackModel,
degraded: modelList.degraded,
});
return noStore(
apiJson({
models: modelList.models,
selectedModel: resolved.model,
fallbackModel: modelList.fallbackModel,
degraded: modelList.degraded,
}),
);
}