diff --git a/ui/src/api/API_README.md b/ui/src/api/API_README.md index 7f18b849b99..9251c9675f6 100644 --- a/ui/src/api/API_README.md +++ b/ui/src/api/API_README.md @@ -280,7 +280,7 @@ Workspace、System 资源管理和 System 共享资源均在各自 `knowledge/kn `postKnowledgeHitTest(knowledgeId, payload)`,向知识库的 `/hit_test` 提交 POST,直接返回命中分段数组。 请求使用 `KnowledgeHitTestPayload`,包含 `query_text`、`image_list`、`top_number`、`similarity` 和 `search_mode`;检索模式复用 `KNOWLEDGE_SEARCH_MODE`。文本和图片至少提供一项,图片仅支持向量或混合检索。 -结果使用 `KnowledgeHitTestResult`,保留分段、得分及图片命中信息。Workspace 共享暂无对应接口,不回退其他范围。 +结果使用 `KnowledgeHitTestResult`,保留分段、得分及图片命中信息;可选 `knowledge_type` 使用 `KnowledgeType` 数字枚举,用于来源图标匹配。Workspace 共享暂无对应接口,不回退其他范围。 向量标签依据 `hit_unit_type`(`KNOWLEDGE_HIT_UNIT_TYPE`):`image` 显示“图片向量”,`text` 显示“文本向量”,图片描述命中也属于文本向量。 `document_resource_type` 表示来源文档类型,`document_image_id` 用于展示图片文档原图,不用于判断命中向量类型。 `query_unit_type` 表示产生该命中的查询输入类型,与 `hit_unit_type` 分别描述查询端和命中端。 @@ -509,6 +509,7 @@ Chat 协议及认证接口见 [chat/README.md](chat/README.md)。 `ChatLogRecord.question` 与 `messages` 使用该内容项类型,扩展字段保留为 `unknown`。 `paragraph_list` 为 `ChatParagraphSource[]`,后端仅在开启「显示知识来源」或调试、日志时返回; 其 `meta` 在历史快照中可能是 JSON 字符串,使用方需兼容字符串与对象。 +分段的 `knowledge_type` 使用可选的 `KnowledgeType` 数字枚举,展示类型映射前先判断字段是否存在。 Chat、Workspace 调试和 System 调试的记录分页及详情均声明 `ChatLogRecord` 返回类型, 消息列表依赖从 `ConversationApiAdapter` 选取对应接口约定。 `conversation-panel/core/stream.ts` 的 `ConversationStream` 通过回调推断分片类型, diff --git a/ui/src/api/types/chat-log.ts b/ui/src/api/types/chat-log.ts index fa059c8dbc9..ea6da585359 100644 --- a/ui/src/api/types/chat-log.ts +++ b/ui/src/api/types/chat-log.ts @@ -1,7 +1,7 @@ import type { CHAT_LOG_SOURCE } from '@/api/enums' import type { Dict } from './common' import type { DocumentResourceType } from './document' -import type { KnowledgeHitTestAsset } from './knowledge' +import type { KnowledgeHitTestAsset, KnowledgeType } from './knowledge' export type ChatLogSource = (typeof CHAT_LOG_SOURCE)[keyof typeof CHAT_LOG_SOURCE] @@ -77,7 +77,7 @@ export interface ChatParagraphSource { hit_asset?: KnowledgeHitTestAsset | null knowledge_id?: string knowledge_name?: string - knowledge_type?: string + knowledge_type?: KnowledgeType /** 历史快照中可能为 JSON 字符串 */ meta?: ChatParagraphSourceMeta | string | null } diff --git a/ui/src/api/types/knowledge.ts b/ui/src/api/types/knowledge.ts index bdacd9b0db3..ee451dad42f 100644 --- a/ui/src/api/types/knowledge.ts +++ b/ui/src/api/types/knowledge.ts @@ -197,6 +197,7 @@ export interface KnowledgeHitTestAsset { /** 召回测试返回的分段与命中得分。 */ export interface KnowledgeHitTestResult extends ParagraphItem { + knowledge_type?: KnowledgeType | null document_image_id?: string | null document_resource_type?: DocumentResourceType | null knowledge_id: string diff --git a/ui/src/conversation-panel/right-sidebar/knowledge-source/index.ts b/ui/src/conversation-panel/right-sidebar/knowledge-source/index.ts index 2573dfff9b2..0856136126c 100644 --- a/ui/src/conversation-panel/right-sidebar/knowledge-source/index.ts +++ b/ui/src/conversation-panel/right-sidebar/knowledge-source/index.ts @@ -1,6 +1,6 @@ import { computed, ref } from 'vue' import { DOCUMENT_RESOURCE_TYPE } from '@/api/enums' -import type { ChatParagraphSource, ChatParagraphSourceMeta } from '@/api/types' +import type { ChatParagraphSource, ChatParagraphSourceMeta, DocumentResourceType, KnowledgeType } from '@/api/types' import { downloadByURL, getFileUrl } from '@/utils/common' import { MsgInfo } from '@/utils/message' import { isPdfDocument, type PreviewDocument } from './document-preview/index' @@ -28,12 +28,13 @@ export interface KnowledgeSourceParagraph { vectorLabel: string imageUrl: string documentName: string + documentResourceType?: DocumentResourceType | null documentAction: SourceDocumentAction /** 来源文档地址,UNAVAILABLE 时为空字符串 */ documentUrl: string allowDownload: boolean knowledgeName: string - knowledgeType?: string + knowledgeType?: KnowledgeType } // 历史快照中 meta 可能是 JSON 字符串,解析失败按无元数据处理 @@ -79,6 +80,7 @@ function toSourceParagraph(paragraph: ChatParagraphSource, index: number): Knowl vectorLabel: paragraph.document_resource_type === DOCUMENT_RESOURCE_TYPE.IMAGE || paragraph.hit_asset ? '图片向量' : '文本向量', imageUrl: getImageUrl(paragraph), documentName, + documentResourceType: paragraph.document_resource_type, documentAction: documentTarget.action, documentUrl: documentTarget.url, allowDownload: meta.allow_download !== false, diff --git a/ui/src/conversation-panel/right-sidebar/knowledge-source/index.vue b/ui/src/conversation-panel/right-sidebar/knowledge-source/index.vue index 1733c279006..ea7db29578f 100644 --- a/ui/src/conversation-panel/right-sidebar/knowledge-source/index.vue +++ b/ui/src/conversation-panel/right-sidebar/knowledge-source/index.vue @@ -1,5 +1,6 @@