feat(asset-ai): add contextual analysis and unmet-demand feedback
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user