feat: 接入一库一工具知识检索

- 编译知识库英文运行名、描述、检索配置和独立 Registration

- 统一最终分数阈值并保持模型上下文、检索事件与引用一致

- 完善 AG-UI 知识库检索运行态与完成态展示
This commit is contained in:
2026-08-29 15:42:21 +08:00
parent 30904f1503
commit 588e810c51
14 changed files with 832 additions and 44 deletions

View File

@@ -5,6 +5,8 @@ import { events } from 'fetch-event-stream';
import { createEventStreamHeaders, resolveApiUrl } from '#/api/request';
import { easyFlowAguiCustomEvent } from './custom-events';
export interface EasyFlowAguiRunOptions {
forwardedProps?: Record<string, unknown>;
onCursor?: (cursor: number) => void;
@@ -101,6 +103,31 @@ function waitForToolStartPaint(): Promise<void> {
});
}
/**
* 判断事件是否开启了需要即时呈现的工具执行状态。
*
* @param event AG-UI 事件
* @returns 标准工具开始或知识库检索开始时为 true
*/
function startsVisibleToolExecution(event: AguiEvent) {
if (event.type === EventType.TOOL_CALL_START) {
return true;
}
if (
event.type !== EventType.CUSTOM ||
event.name !== easyFlowAguiCustomEvent.knowledgeRetrievalStatus
) {
return false;
}
const value =
event.value &&
typeof event.value === 'object' &&
!Array.isArray(event.value)
? (event.value as Record<string, unknown>)
: {};
return String(value.status || '').toLowerCase() === 'running';
}
/**
* EasyFlow 的无头 AG-UI 运行客户端。
*
@@ -174,7 +201,7 @@ export class EasyFlowAguiClient {
) {
terminalReceived = true;
}
if (event.type === EventType.TOOL_CALL_START) {
if (startsVisibleToolExecution(event as AguiEvent)) {
await waitForToolStartPaint();
}
}
@@ -233,7 +260,7 @@ export class EasyFlowAguiClient {
if (Number.isSafeInteger(cursor) && cursor > 0) {
options.onCursor?.(cursor);
}
if (event.type === EventType.TOOL_CALL_START) {
if (startsVisibleToolExecution(event as AguiEvent)) {
await waitForToolStartPaint();
}
}