feat(asset-ai): add contextual analysis and unmet-demand feedback

This commit is contained in:
shishengliang
2026-09-23 16:01:10 +08:00
parent 0a32392215
commit 7e9760f5db
23 changed files with 5160 additions and 835 deletions
+16 -3
View File
@@ -1,11 +1,21 @@
import { fetchAuthenticated } from "../../../auth/api-client";
import type {
AssistantEvent,
QueryPlan,
AssistantRequest,
} from "../../../shared/assets/assistant";
export class AssistantRequestError extends Error {
constructor(
message: string,
public status: number,
) {
super(message);
this.name = "AssistantRequestError";
}
}
export async function askAssetAssistant(
input: { message: string; subject: string | null; previous?: QueryPlan },
input: AssistantRequest,
signal: AbortSignal,
onEvent: (event: AssistantEvent) => void,
) {
@@ -17,7 +27,10 @@ export async function askAssetAssistant(
});
if (!response.ok) {
const body = await response.json().catch(() => null);
throw new Error(body?.error || "查询服务暂时不可用。");
throw new AssistantRequestError(
body?.error || "查询服务暂时不可用。",
response.status,
);
}
if (!response.body) throw new Error("当前浏览器无法读取查询进度。");
const reader = response.body.getReader();