feat: Add agent configuration and cleanup scripts for database migrations
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div class="chunk-detail">
|
||||
<div class="info-section">
|
||||
<div class="info-field">
|
||||
<span class="field-label">片段ID:</span>
|
||||
<span class="field-value"><code>{{ data.chunk_id }}</code></span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">文档ID:</span>
|
||||
<span class="field-value"><code>{{ data.knowledge_id }}</code></span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">位置:</span>
|
||||
<span class="field-value">第 {{ data.chunk_index }} 个片段</span>
|
||||
</div>
|
||||
<div v-if="data.content_length" class="info-field">
|
||||
<span class="field-label">内容长度:</span>
|
||||
<span class="field-value">{{ data.content_length }} 字符</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<div class="info-section-title">完整内容</div>
|
||||
<div class="full-content">{{ data.content }}</div>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<div class="action-buttons">
|
||||
<button class="action-button" @click="copyToClipboard">
|
||||
📋 复制内容
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineProps } from 'vue';
|
||||
import type { ChunkDetailData } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: ChunkDetailData;
|
||||
}>();
|
||||
|
||||
const copyToClipboard = () => {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(props.data.content);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import './tool-results.less';
|
||||
|
||||
.chunk-detail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
background: #f0f0f0;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
<template>
|
||||
<div class="database-query-display">
|
||||
<!-- Query Display -->
|
||||
<div v-if="data.query" class="query-section">
|
||||
<div class="section-header">执行的 SQL 查询:</div>
|
||||
<pre class="query-code">{{ data.query }}</pre>
|
||||
</div>
|
||||
|
||||
<!-- Results Summary -->
|
||||
<div class="results-summary">
|
||||
<strong>返回结果:</strong> {{ data.row_count }} 行
|
||||
<span v-if="data.columns"> × {{ data.columns.length }} 列</span>
|
||||
</div>
|
||||
|
||||
<!-- Results Table -->
|
||||
<div v-if="data.rows && data.rows.length > 0" class="results-table-container">
|
||||
<table class="results-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th v-for="column in data.columns" :key="column">{{ column }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(row, index) in data.rows" :key="index">
|
||||
<td v-for="column in data.columns" :key="column">
|
||||
{{ formatValue(row[column]) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- No Results -->
|
||||
<div v-else class="no-results">
|
||||
未找到匹配的记录
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { DatabaseQueryData } from '@/types/tool-results';
|
||||
|
||||
interface Props {
|
||||
data: DatabaseQueryData;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const formatValue = (value: any): string => {
|
||||
if (value === null || value === undefined) {
|
||||
return '<NULL>';
|
||||
}
|
||||
if (typeof value === 'object') {
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
return String(value);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.database-query-display {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.query-section {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
margin-bottom: 8px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.query-code {
|
||||
background: #1e293b;
|
||||
color: #e2e8f0;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
overflow-x: auto;
|
||||
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.results-summary {
|
||||
padding: 10px 12px;
|
||||
background: #f0f9ff;
|
||||
border-left: 3px solid #3b82f6;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 13px;
|
||||
|
||||
strong {
|
||||
color: #1e40af;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.results-table-container {
|
||||
overflow-x: auto;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.results-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 12px;
|
||||
|
||||
thead {
|
||||
background: #f9fafb;
|
||||
border-bottom: 2px solid #e5e7eb;
|
||||
|
||||
th {
|
||||
padding: 10px 12px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
color: #374151;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
tbody {
|
||||
tr {
|
||||
border-bottom: 1px solid #f3f4f6;
|
||||
|
||||
&:hover {
|
||||
background: #f9fafb;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 10px 12px;
|
||||
color: #1f2937;
|
||||
vertical-align: top;
|
||||
max-width: 400px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.no-results {
|
||||
padding: 32px;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-style: italic;
|
||||
background: #f9fafb;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #e5e7eb;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<template>
|
||||
<div class="document-info">
|
||||
<div class="info-card">
|
||||
<div class="info-section">
|
||||
<div class="info-field">
|
||||
<span class="field-label">文档ID:</span>
|
||||
<span class="field-value"><code>{{ data.knowledge_id }}</code></span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">文档标题:</span>
|
||||
<span class="field-value">{{ data.title }}</span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">片段数量:</span>
|
||||
<span class="field-value">至少 {{ data.chunk_count_min }} 个</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-section">
|
||||
<div class="status-title">状态说明</div>
|
||||
<div class="status-list">
|
||||
<div class="status-item">✓ 文档已索引并可搜索</div>
|
||||
<div class="status-item">✓ 可使用搜索工具查找文档内容</div>
|
||||
<div class="status-item">✓ 可使用 get_chunk_detail 查看片段详情</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineProps } from 'vue';
|
||||
import type { DocumentInfoData } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: DocumentInfoData;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import './tool-results.less';
|
||||
|
||||
.document-info {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
background: @card-bg;
|
||||
border: 1px solid @card-border;
|
||||
border-radius: @card-radius;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.status-section {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid @card-border;
|
||||
}
|
||||
|
||||
.status-title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.status-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.status-item {
|
||||
font-size: 12px;
|
||||
color: #00a870;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
background: #f0f0f0;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<template>
|
||||
<div class="graph-query-results">
|
||||
<!-- Graph Configuration Card -->
|
||||
<div v-if="data.graph_config" class="stats-card">
|
||||
<div class="stats-title">图谱配置</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">实体类型:</span>
|
||||
<span class="field-value">{{ data.graph_config.nodes.join(', ') }}</span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">关系类型:</span>
|
||||
<span class="field-value">{{ data.graph_config.relations.join(', ') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Results List -->
|
||||
<div v-if="data.results && data.results.length > 0" class="results-list">
|
||||
<div class="results-header">
|
||||
找到 {{ data.count }} 条相关结果
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="result in data.results"
|
||||
:key="result.chunk_id"
|
||||
class="result-card"
|
||||
>
|
||||
<div class="result-header" @click="toggleResult(result.chunk_id)">
|
||||
<div class="result-title">
|
||||
<span class="result-index">#{{ result.result_index }}</span>
|
||||
<span class="relevance-badge" :class="getRelevanceClass(result.relevance_level)">
|
||||
{{ result.relevance_level }}
|
||||
</span>
|
||||
<span class="knowledge-title">{{ result.knowledge_title }}</span>
|
||||
</div>
|
||||
<div class="result-meta">
|
||||
<span class="score">{{ (result.score * 100).toFixed(0) }}%</span>
|
||||
<span class="expand-icon" :class="{ expanded: expandedResults.includes(result.chunk_id) }">
|
||||
▶
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="result-content" :class="{ expanded: expandedResults.includes(result.chunk_id) }">
|
||||
<div class="full-content">{{ result.content }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="empty-state">
|
||||
未找到相关的图谱信息
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, defineProps } from 'vue';
|
||||
import type { GraphQueryResultsData, RelevanceLevel } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: GraphQueryResultsData;
|
||||
}>();
|
||||
|
||||
const expandedResults = ref<string[]>([]);
|
||||
|
||||
const toggleResult = (chunkId: string) => {
|
||||
const index = expandedResults.value.indexOf(chunkId);
|
||||
if (index > -1) {
|
||||
expandedResults.value.splice(index, 1);
|
||||
} else {
|
||||
expandedResults.value.push(chunkId);
|
||||
}
|
||||
};
|
||||
|
||||
const getRelevanceClass = (level: RelevanceLevel): string => {
|
||||
const classMap: Record<RelevanceLevel, string> = {
|
||||
'高相关': 'high',
|
||||
'中相关': 'medium',
|
||||
'低相关': 'low',
|
||||
'弱相关': 'weak',
|
||||
};
|
||||
return classMap[level] || 'weak';
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import './tool-results.less';
|
||||
|
||||
.graph-query-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.results-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.results-header {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.result-index {
|
||||
font-size: 13px;
|
||||
color: #8b8b8b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.knowledge-title {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.score {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<div class="knowledge-base-list">
|
||||
<div v-if="data.knowledge_bases && data.knowledge_bases.length > 0">
|
||||
<div class="stats-card">
|
||||
<div class="stats-title">共 {{ data.count }} 个知识库</div>
|
||||
</div>
|
||||
|
||||
<div class="card-grid">
|
||||
<div
|
||||
v-for="kb in data.knowledge_bases"
|
||||
:key="kb.id"
|
||||
class="kb-card"
|
||||
>
|
||||
<div class="kb-header">
|
||||
<span class="kb-index">#{{ kb.index }}</span>
|
||||
<span class="kb-name">{{ kb.name }}</span>
|
||||
</div>
|
||||
<div class="kb-body">
|
||||
<div class="info-field">
|
||||
<span class="field-label">ID:</span>
|
||||
<span class="field-value"><code>{{ kb.id }}</code></span>
|
||||
</div>
|
||||
<div v-if="kb.description" class="kb-description">
|
||||
{{ kb.description }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="empty-state">
|
||||
没有可用的知识库
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineProps } from 'vue';
|
||||
import type { KnowledgeBaseListData } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: KnowledgeBaseListData;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import './tool-results.less';
|
||||
|
||||
.knowledge-base-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.kb-card {
|
||||
background: @card-bg;
|
||||
border: 1px solid @card-border;
|
||||
border-radius: @card-radius;
|
||||
padding: 12px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: @card-hover-border;
|
||||
box-shadow: @card-shadow-hover;
|
||||
}
|
||||
}
|
||||
|
||||
.kb-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.kb-index {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.kb-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.kb-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.kb-description {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
background: #f0f0f0;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<div class="plan-display">
|
||||
<div v-if="data.task" class="plan-task">
|
||||
<strong>任务:</strong> {{ data.task }}
|
||||
</div>
|
||||
|
||||
<div v-if="data.steps && data.steps.length > 0" class="plan-steps">
|
||||
<div class="steps-header">计划步骤 (共 {{ data.total_steps || data.steps.length }} 步):</div>
|
||||
<div v-for="(step, index) in data.steps" :key="step.id || index" class="step-item">
|
||||
<div class="step-header">
|
||||
<span class="step-number">{{ index + 1 }}.</span>
|
||||
<span class="step-status" :class="`status-${step.status}`">
|
||||
{{ getStatusEmoji(step.status) }}
|
||||
</span>
|
||||
<span class="step-status-text" :class="`status-${step.status}`">
|
||||
[{{ getStatusText(step.status) }}]
|
||||
</span>
|
||||
<span class="step-description">{{ step.description }}</span>
|
||||
</div>
|
||||
<div v-if="step.tools_to_use" class="step-tools">
|
||||
<span class="tools-label">工具:</span> {{ step.tools_to_use }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="no-steps">
|
||||
未提供具体步骤
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import type { PlanData } from '@/types/tool-results';
|
||||
|
||||
interface Props {
|
||||
data: PlanData;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const getStatusEmoji = (status: string): string => {
|
||||
const emojiMap: Record<string, string> = {
|
||||
pending: '⏳',
|
||||
in_progress: '🔄',
|
||||
completed: '✅',
|
||||
skipped: '⏭️'
|
||||
};
|
||||
return emojiMap[status] || '⏳';
|
||||
};
|
||||
|
||||
const getStatusText = (status: string): string => {
|
||||
const textMap: Record<string, string> = {
|
||||
pending: '待处理',
|
||||
in_progress: '进行中',
|
||||
completed: '已完成',
|
||||
skipped: '已跳过'
|
||||
};
|
||||
return textMap[status] || status;
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.plan-display {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
background: #f9fafb;
|
||||
padding: 12px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #e5e7eb;
|
||||
}
|
||||
|
||||
.plan-task {
|
||||
margin-bottom: 16px;
|
||||
padding: 10px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
border-left: 3px solid #3b82f6;
|
||||
|
||||
strong {
|
||||
color: #1f2937;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.plan-steps {
|
||||
.steps-header {
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.step-item {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e5e7eb;
|
||||
transition: all 0.2s;
|
||||
|
||||
&:hover {
|
||||
border-color: #d1d5db;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.step-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.step-number {
|
||||
font-weight: 600;
|
||||
color: #6b7280;
|
||||
min-width: 20px;
|
||||
}
|
||||
|
||||
.step-status {
|
||||
font-size: 16px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.step-status-text {
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
|
||||
&.status-pending {
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
&.status-in_progress {
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
&.status-completed {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
&.status-skipped {
|
||||
color: #9ca3af;
|
||||
}
|
||||
}
|
||||
|
||||
.step-description {
|
||||
flex: 1;
|
||||
color: #1f2937;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.step-tools {
|
||||
margin-top: 6px;
|
||||
padding-left: 26px;
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
|
||||
.tools-label {
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
|
||||
.no-steps {
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<template>
|
||||
<div class="related-chunks">
|
||||
<div class="info-section">
|
||||
<div class="info-field">
|
||||
<span class="field-label">参考片段:</span>
|
||||
<span class="field-value"><code>{{ data.chunk_id }}</code></span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">关系类型:</span>
|
||||
<span class="field-value">{{ relationTypeLabel }}</span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">相关片段数:</span>
|
||||
<span class="field-value">{{ data.count }} 个</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="data.chunks && data.chunks.length > 0" class="chunks-list">
|
||||
<div
|
||||
v-for="chunk in data.chunks"
|
||||
:key="chunk.chunk_id"
|
||||
class="result-card"
|
||||
>
|
||||
<div class="result-header" @click="toggleChunk(chunk.chunk_id)">
|
||||
<div class="result-title">
|
||||
<span class="chunk-index">片段 #{{ chunk.index }}</span>
|
||||
<span class="chunk-position">(位置: {{ chunk.chunk_index }})</span>
|
||||
</div>
|
||||
<span class="expand-icon" :class="{ expanded: expandedChunks.includes(chunk.chunk_id) }">
|
||||
▶
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="result-content" :class="{ expanded: expandedChunks.includes(chunk.chunk_id) }">
|
||||
<div class="info-field">
|
||||
<span class="field-label">片段ID:</span>
|
||||
<span class="field-value"><code>{{ chunk.chunk_id }}</code></span>
|
||||
</div>
|
||||
<div class="info-section">
|
||||
<div class="info-section-title">内容</div>
|
||||
<div class="full-content">{{ chunk.content }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="empty-state">
|
||||
没有找到相关片段
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, defineProps, computed } from 'vue';
|
||||
import type { RelatedChunksData } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: RelatedChunksData;
|
||||
}>();
|
||||
|
||||
const expandedChunks = ref<string[]>([]);
|
||||
|
||||
const relationTypeLabel = computed(() => {
|
||||
const labels: Record<string, string> = {
|
||||
'sequential': '顺序相关',
|
||||
'semantic': '语义相关',
|
||||
};
|
||||
return labels[props.data.relation_type] || props.data.relation_type;
|
||||
});
|
||||
|
||||
const toggleChunk = (chunkId: string) => {
|
||||
const index = expandedChunks.value.indexOf(chunkId);
|
||||
if (index > -1) {
|
||||
expandedChunks.value.splice(index, 1);
|
||||
} else {
|
||||
expandedChunks.value.push(chunkId);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import './tool-results.less';
|
||||
|
||||
.related-chunks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.chunks-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.chunk-index {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.chunk-position {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
background: #f0f0f0;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<div class="search-results">
|
||||
<!-- Knowledge Base Statistics Card -->
|
||||
<div v-if="kbCounts && Object.keys(kbCounts).length > 0" class="stats-card">
|
||||
<div class="stats-title">知识库覆盖</div>
|
||||
<div class="stats-list">
|
||||
<div v-for="(count, kbId) in kbCounts" :key="kbId" class="stats-item">
|
||||
<span>{{ kbId }}</span>
|
||||
<span>{{ count }} 条结果</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Search Results List -->
|
||||
<div v-if="results && results.length > 0" class="results-list">
|
||||
<div
|
||||
v-for="result in results"
|
||||
:key="result.chunk_id"
|
||||
class="result-card"
|
||||
>
|
||||
<div class="result-header" @click="toggleResult(result.chunk_id)">
|
||||
<div class="result-title">
|
||||
<span class="result-index">#{{ result.result_index }}</span>
|
||||
<span class="relevance-badge" :class="getRelevanceClass(result.relevance_level)">
|
||||
{{ result.relevance_level }}
|
||||
</span>
|
||||
<span class="knowledge-title">{{ result.knowledge_title }}</span>
|
||||
</div>
|
||||
<div class="result-meta">
|
||||
<span class="match-type-badge">
|
||||
{{ getMatchTypeIcon(result.match_type) }} {{ result.match_type }}
|
||||
</span>
|
||||
<span class="score">{{ (result.score * 100).toFixed(0) }}%</span>
|
||||
<span class="expand-icon" :class="{ expanded: expandedResults.includes(result.chunk_id) }">
|
||||
▶
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="result-content" :class="{ expanded: expandedResults.includes(result.chunk_id) }">
|
||||
<div class="info-section">
|
||||
<div class="info-section-title">内容</div>
|
||||
<div class="full-content">{{ result.content }}</div>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<div class="info-field">
|
||||
<span class="field-label">片段ID:</span>
|
||||
<span class="field-value"><code>{{ result.chunk_id }}</code></span>
|
||||
</div>
|
||||
<div class="info-field">
|
||||
<span class="field-label">文档ID:</span>
|
||||
<span class="field-value"><code>{{ result.knowledge_id }}</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div v-else class="empty-state">
|
||||
没有找到搜索结果
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, defineProps, computed } from 'vue';
|
||||
import type { SearchResultsData, SearchResultItem, RelevanceLevel } from '@/types/tool-results';
|
||||
import { getMatchTypeIcon } from '@/utils/tool-icons';
|
||||
|
||||
const props = defineProps<{
|
||||
data: SearchResultsData;
|
||||
}>();
|
||||
|
||||
const expandedResults = ref<string[]>([]);
|
||||
|
||||
const results = computed(() => props.data.results || []);
|
||||
const kbCounts = computed(() => props.data.kb_counts);
|
||||
|
||||
const toggleResult = (chunkId: string) => {
|
||||
const index = expandedResults.value.indexOf(chunkId);
|
||||
if (index > -1) {
|
||||
expandedResults.value.splice(index, 1);
|
||||
} else {
|
||||
expandedResults.value.push(chunkId);
|
||||
}
|
||||
};
|
||||
|
||||
const getRelevanceClass = (level: RelevanceLevel): string => {
|
||||
const classMap: Record<RelevanceLevel, string> = {
|
||||
'高相关': 'high',
|
||||
'中相关': 'medium',
|
||||
'低相关': 'low',
|
||||
'弱相关': 'weak',
|
||||
};
|
||||
return classMap[level] || 'weak';
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import './tool-results.less';
|
||||
|
||||
.search-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.results-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.result-index {
|
||||
font-size: 13px;
|
||||
color: #8b8b8b;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.knowledge-title {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.score {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
background: #f0f0f0;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<div class="thinking-display">
|
||||
<div class="thinking-content">
|
||||
<div class="thinking-icon">💭</div>
|
||||
<div class="thinking-text">{{ data.thought }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { defineProps } from 'vue';
|
||||
import type { ThinkingData } from '@/types/tool-results';
|
||||
|
||||
const props = defineProps<{
|
||||
data: ThinkingData;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
@import './tool-results.less';
|
||||
|
||||
.thinking-display {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.thinking-content {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
background: #f3f3f3;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid #8b8b8b;
|
||||
}
|
||||
|
||||
.thinking-icon {
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.thinking-text {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* Tool Results Shared Styles
|
||||
* Common styles for all tool result components
|
||||
*/
|
||||
|
||||
// Color scheme for relevance levels
|
||||
@relevance-high: #00a870;
|
||||
@relevance-medium: #ff9800;
|
||||
@relevance-low: #757575;
|
||||
@relevance-weak: #bdbdbd;
|
||||
|
||||
// Card colors
|
||||
@card-bg: #f8f9fa;
|
||||
@card-border: #e7e7e7;
|
||||
@card-hover-border: #07c05f;
|
||||
@card-radius: 8px;
|
||||
@card-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
@card-shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
|
||||
// Animation timing
|
||||
@transition-time: 0.3s;
|
||||
|
||||
// Tool result container
|
||||
.tool-result-container {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
// Relevance badge styles
|
||||
.relevance-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
gap: 4px;
|
||||
|
||||
&.high {
|
||||
background-color: @relevance-high;
|
||||
color: white;
|
||||
}
|
||||
|
||||
&.medium {
|
||||
background-color: @relevance-medium;
|
||||
color: white;
|
||||
}
|
||||
|
||||
&.low {
|
||||
background-color: @relevance-low;
|
||||
color: white;
|
||||
}
|
||||
|
||||
&.weak {
|
||||
background-color: @relevance-weak;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
// Match type badge
|
||||
.match-type-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
background-color: #e7e7e7;
|
||||
color: #666;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
// Result card
|
||||
.result-card {
|
||||
background: @card-bg;
|
||||
border: 1px solid @card-border;
|
||||
border-radius: @card-radius;
|
||||
margin-bottom: 8px;
|
||||
overflow: hidden;
|
||||
transition: all @transition-time ease;
|
||||
|
||||
&:hover {
|
||||
border-color: @card-hover-border;
|
||||
box-shadow: @card-shadow-hover;
|
||||
}
|
||||
}
|
||||
|
||||
.result-header {
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
.result-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.result-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
}
|
||||
|
||||
.result-content {
|
||||
padding: 0 12px 12px 12px;
|
||||
border-top: 1px solid @card-border;
|
||||
background: white;
|
||||
max-height: 0;
|
||||
opacity: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height @transition-time ease, opacity @transition-time ease, padding @transition-time ease;
|
||||
|
||||
&.expanded {
|
||||
max-height: 2000px;
|
||||
opacity: 1;
|
||||
padding: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
transition: transform 0.2s ease;
|
||||
|
||||
&.expanded {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
|
||||
// Info sections
|
||||
.info-section {
|
||||
margin-top: 12px;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.info-section-title {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.info-field {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
font-size: 13px;
|
||||
|
||||
.field-label {
|
||||
color: #8b8b8b;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.field-value {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Statistics card (for KB counts, etc.)
|
||||
.stats-card {
|
||||
background: #f0f7ff;
|
||||
border: 1px solid #d6e4ff;
|
||||
border-radius: 6px;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.stats-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.stats-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stats-item {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
// Grid layout for cards
|
||||
.card-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
// List item
|
||||
.list-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
// Content preview (truncated)
|
||||
.content-preview {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
max-height: 60px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
||||
|
||||
// Full content
|
||||
.full-content {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
padding: 8px;
|
||||
background: #f5f5f5;
|
||||
border-radius: 4px;
|
||||
border: 1px solid @card-border;
|
||||
}
|
||||
|
||||
// Action buttons
|
||||
.action-button {
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid @card-border;
|
||||
background: white;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
border-color: @card-hover-border;
|
||||
color: @card-hover-border;
|
||||
}
|
||||
}
|
||||
|
||||
// Empty state
|
||||
.empty-state {
|
||||
padding: 24px;
|
||||
text-align: center;
|
||||
color: #8b8b8b;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
// Code block
|
||||
.code-block {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
background: #f5f5f5;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid @card-border;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user