feat(know-tool-calling): 增强知识库工具结果显示功能
支持 get_mindmap 操作的纯文本显示 优化搜索结果的展示样式和参数解析 移除未使用的 FileTextOutlined 图标
This commit is contained in:
parent
e9681c8a32
commit
148dcf2e43
@ -14,7 +14,9 @@
|
||||
- 考虑修改附件的处理逻辑,考虑使用文件系统,将附件解析后放到文件系统中,智能体按需读取,用户可以使用 @ 来引用附件,例如 @file:reports.md 相较于现在的处理逻辑感觉会更加自然一点。在此之前可能还要考虑文件系统的后端支持问题
|
||||
- skills 如何实现还需要继续调研
|
||||
- 优化 paddle 的命名,paddlex 有歧义,修改为 PP-StructureV3
|
||||
- 增加 paddle-vl 以及 deepseek-ocr 的支持
|
||||
- 增加 paddle-vl 以及 deepseek-ocr 的支持(deepseek-ocr 已支持)
|
||||
- RAG 检索的时候,支持限定文件类型
|
||||
- 将现有的 Milvus 的命名调整为通用 RAG
|
||||
|
||||
### Bugs
|
||||
- 部分异常状态下,智能体的模型名称出现重叠[#279](https://github.com/xerrors/Yuxi-Know/issues/279)
|
||||
|
||||
@ -97,8 +97,9 @@ const isKnowledgeBaseResult = computed(() => {
|
||||
const hasKnowledgebaseTag = metadata.tag && metadata.tag.includes('knowledgebase');
|
||||
const isNotLightrag = metadata.kb_type !== 'lightrag';
|
||||
if (hasKnowledgebaseTag && isNotLightrag) {
|
||||
const data = parseData(props.toolCall.tool_call_result?.content);
|
||||
return Array.isArray(data) && data.length > 0;
|
||||
// const data = parseData(props.toolCall.tool_call_result?.content);
|
||||
// return Array.isArray(data) && data.length > 0;
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -1,7 +1,22 @@
|
||||
<template>
|
||||
<BaseToolCall :tool-call="toolCall">
|
||||
<BaseToolCall :tool-call="toolCall" :hide-params="true">
|
||||
<template #header>
|
||||
<div class="sep-header">
|
||||
<span class="note">{{ operationLabel }}</span>
|
||||
<span class="separator" v-if="queryText">|</span>
|
||||
<span class="description">"{{ queryText }}"</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #result="{ resultContent }">
|
||||
<div class="knowledge-base-result">
|
||||
<!-- get_mindmap 操作:纯文本显示 -->
|
||||
<div v-if="operation === 'get_mindmap'" class="knowledge-base-result">
|
||||
<div class="mindmap-result">
|
||||
<pre class="mindmap-content">{{ formatMindmapResult(resultContent) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- search 操作:原有的文件分组显示 -->
|
||||
<div v-else class="knowledge-base-result">
|
||||
<div class="result-summary">
|
||||
找到 {{ parsedData(resultContent).length }} 个相关文档片段,来自 {{ fileGroups(parsedData(resultContent)).length }} 个文件
|
||||
</div>
|
||||
@ -109,7 +124,7 @@
|
||||
<script setup>
|
||||
import BaseToolCall from '../BaseToolCall.vue';
|
||||
import { ref, computed } from 'vue'
|
||||
import { FileTextOutlined, FileOutlined, DownOutlined, EyeOutlined, DatabaseOutlined } from '@ant-design/icons-vue'
|
||||
import { FileOutlined, DownOutlined, EyeOutlined, DatabaseOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
const props = defineProps({
|
||||
toolCall: {
|
||||
@ -118,6 +133,38 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
// 解析参数
|
||||
const args = computed(() => {
|
||||
const args = props.toolCall.args || props.toolCall.function?.arguments;
|
||||
if (!args) return {};
|
||||
|
||||
if (typeof args === 'object') return args;
|
||||
try {
|
||||
return JSON.parse(args);
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
});
|
||||
|
||||
// 获取操作类型
|
||||
const operation = computed(() => {
|
||||
return args.value.operation || 'search';
|
||||
});
|
||||
|
||||
// 获取操作标签
|
||||
const operationLabel = computed(() => {
|
||||
const labels = {
|
||||
search: `${props.toolCall.name} 搜索`,
|
||||
get_mindmap: props.toolCall.name
|
||||
};
|
||||
return labels[operation.value] || operation.value;
|
||||
});
|
||||
|
||||
// 获取查询文本
|
||||
const queryText = computed(() => {
|
||||
return args.value.query_text || '';
|
||||
});
|
||||
|
||||
const parseData = (content) => {
|
||||
if (typeof content === 'string') {
|
||||
try {
|
||||
@ -194,6 +241,17 @@ const getScoreColor = (score) => {
|
||||
if (score >= 0.5) return '#faad14' // 橙色 - 中等相关性
|
||||
return '#ff4d4f' // 红色 - 低相关性
|
||||
}
|
||||
|
||||
// 格式化思维导图结果
|
||||
const formatMindmapResult = (content) => {
|
||||
if (typeof content === 'string') {
|
||||
return content;
|
||||
}
|
||||
if (typeof content === 'object') {
|
||||
return JSON.stringify(content, null, 2);
|
||||
}
|
||||
return String(content);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@ -202,6 +260,22 @@ const getScoreColor = (score) => {
|
||||
border-radius: 8px;
|
||||
// border: 1px solid var(--gray-200);
|
||||
|
||||
.mindmap-result {
|
||||
padding: 12px 16px;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
|
||||
.mindmap-content {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: var(--gray-700);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
||||
}
|
||||
}
|
||||
|
||||
.result-summary {
|
||||
padding: 12px 16px;
|
||||
background: var(--gray-25);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user