feat: Integrate Swiper library and enhance chat functionality
- Added Swiper library to package dependencies for improved UI components. - Updated chat API to include summary model ID in message handling, allowing for more flexible model selection. - Enhanced InputField component to manage model selection and state more effectively. - Improved event handling in chat components to support new model features and ensure accurate message processing. - Refactored SVG assets for better visual consistency and updated styles for improved user experience.
@@ -28,7 +28,7 @@ export function useStream() {
|
||||
let renderTimer: number | null = null
|
||||
|
||||
// 启动流式请求
|
||||
const startStream = async (params: { session_id: any; query: any; knowledge_base_ids?: string[]; agent_enabled?: boolean; method: string; url: string }) => {
|
||||
const startStream = async (params: { session_id: any; query: any; knowledge_base_ids?: string[]; agent_enabled?: boolean; summary_model_id?: string; method: string; url: string }) => {
|
||||
// 重置状态
|
||||
output.value = '';
|
||||
error.value = null;
|
||||
@@ -69,6 +69,10 @@ export function useStream() {
|
||||
if (params.knowledge_base_ids !== undefined && params.knowledge_base_ids.length > 0) {
|
||||
postBody.knowledge_base_ids = params.knowledge_base_ids;
|
||||
}
|
||||
// Include summary_model_id if provided (for non-Agent mode)
|
||||
if (params.summary_model_id) {
|
||||
postBody.summary_model_id = params.summary_model_id;
|
||||
}
|
||||
|
||||
await fetchEventSource(url, {
|
||||
method: params.method,
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface ModelConfig {
|
||||
truncate_prompt_tokens?: number;
|
||||
};
|
||||
interface_type?: 'ollama' | 'openai'; // VLLM专用
|
||||
parameter_size?: string; // Ollama模型参数大小 (e.g., "7B", "13B", "70B")
|
||||
};
|
||||
is_default?: boolean;
|
||||
status?: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" class="r4oyk8abi__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 2C5.79086 2 4 3.79086 4 6C4 7.56981 4.90422 8.92935 6.22252 9.58448C6.39251 9.66896 6.5 9.84241 6.5 10.0322V11H9.5V10.0322C9.5 9.84241 9.60749 9.66896 9.77748 9.58448C11.0958 8.92935 12 7.56981 12 6C12 3.79086 10.2091 2 8 2ZM3 6C3 3.23858 5.23858 1 8 1C10.7614 1 13 3.23858 13 6C13 7.85144 11.9936 9.46702 10.5 10.331V11.5C10.5 11.7761 10.2761 12 10 12H6C5.72386 12 5.5 11.7761 5.5 11.5V10.331C4.00636 9.46702 3 7.85144 3 6Z" fill="#32CE3F"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 13.5H6V12.5H10V13.5Z" fill="#32CE3F"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 15H7V14H9V15Z" fill="#32CE3F"></path>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.4269 5.11946L7.60516 7.94123L5.7821 6.11819L6.48921 5.41108L7.60516 6.52702L9.71982 4.41235L10.4269 5.11946Z" fill="#32CE3F"></path>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 2C5.79086 2 4 3.79086 4 6C4 7.56981 4.90422 8.92935 6.22252 9.58448C6.39251 9.66896 6.5 9.84241 6.5 10.0322V11H9.5V10.0322C9.5 9.84241 9.60749 9.66896 9.77748 9.58448C11.0958 8.92935 12 7.56981 12 6C12 3.79086 10.2091 2 8 2ZM3 6C3 3.23858 5.23858 1 8 1C10.7614 1 13 3.23858 13 6C13 7.85144 11.9936 9.46702 10.5 10.331V11.5C10.5 11.7761 10.2761 12 10 12H6C5.72386 12 5.5 11.7761 5.5 11.5V10.331C4.00636 9.46702 3 7.85144 3 6Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.3"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 13.5H6V12.5H10V13.5Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.3"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 15H7V14H9V15Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.3"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.4269 5.11946L7.60516 7.94123L5.7821 6.11819L6.48921 5.41108L7.60516 6.52702L9.71982 4.41235L10.4269 5.11946Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.3"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1022 B After Width: | Height: | Size: 1.1 KiB |
@@ -1,5 +1,5 @@
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="rgba(0,0,0,0.15)" stroke="rgba(0,0,0,0.3)" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="rgba(0,0,0,0.15)" stroke="rgba(0,0,0,0.3)" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="rgba(0,0,0,0.15)" stroke="rgba(0,0,0,0.3)" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
<path d="M10 3L10.8 6.2C10.9 6.7 11.3 7.1 11.8 7.2L15 8L11.8 8.8C11.3 8.9 10.9 9.3 10.8 9.8L10 13L9.2 9.8C9.1 9.3 8.7 8.9 8.2 8.8L5 8L8.2 7.2C8.7 7.1 9.1 6.7 9.2 6.2L10 3Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.8" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15.5 4L15.8 5.2C15.85 5.45 16.05 5.65 16.3 5.7L17.5 6L16.3 6.3C16.05 6.35 15.85 6.55 15.8 6.8L15.5 8L15.2 6.8C15.15 6.55 14.95 6.35 14.7 6.3L13.5 6L14.7 5.7C14.95 5.65 15.15 5.45 15.2 5.2L15.5 4Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M4.5 13L4.8 14.2C4.85 14.45 5.05 14.65 5.3 14.7L6.5 15L5.3 15.3C5.05 15.35 4.85 15.55 4.8 15.8L4.5 17L4.2 15.8C4.15 15.55 3.95 15.35 3.7 15.3L2.5 15L3.7 14.7C3.95 14.65 4.15 14.45 4.2 14.2L4.5 13Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 995 B |
@@ -0,0 +1,82 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
|
||||
<!-- Background -->
|
||||
<defs>
|
||||
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" style="stop-color:#F0FDF4;stop-opacity:1" />
|
||||
<stop offset="100%" style="stop-color:#DCFCE7;stop-opacity:1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="800" height="600" fill="url(#grad1)"/>
|
||||
|
||||
<!-- Decorative circles -->
|
||||
<circle cx="100" cy="80" r="100" fill="#10B981" opacity="0.04"/>
|
||||
<circle cx="700" cy="520" r="120" fill="#10B981" opacity="0.04"/>
|
||||
|
||||
<!-- Title -->
|
||||
<text x="400" y="70" font-family="PingFang SC, sans-serif" font-size="36" font-weight="700" fill="#065F46" text-anchor="middle">智能文档检索</text>
|
||||
<text x="400" y="105" font-family="PingFang SC, sans-serif" font-size="16" fill="#059669" text-anchor="middle">多模态文档解析 • 语义理解 • 精准检索</text>
|
||||
|
||||
<!-- Search Interface -->
|
||||
<g transform="translate(100, 150)">
|
||||
<!-- Search box with icon -->
|
||||
<rect width="600" height="60" rx="12" fill="white" stroke="#10B981" stroke-width="2.5" filter="drop-shadow(0 4px 20px rgba(16, 185, 129, 0.15))"/>
|
||||
<circle cx="35" cy="30" r="12" stroke="#10B981" stroke-width="2.5" fill="none"/>
|
||||
<line x1="44" y1="39" x2="52" y2="47" stroke="#10B981" stroke-width="2.5" stroke-linecap="round"/>
|
||||
<text x="70" y="36" font-family="PingFang SC, sans-serif" font-size="16" fill="#9CA3AF">输入查询内容进行智能检索...</text>
|
||||
|
||||
<!-- Search button -->
|
||||
<rect x="480" y="12" width="100" height="36" rx="8" fill="#10B981"/>
|
||||
<text x="530" y="36" font-family="PingFang SC, sans-serif" font-size="15" font-weight="600" fill="white" text-anchor="middle">检索</text>
|
||||
</g>
|
||||
|
||||
<!-- Document Results -->
|
||||
<!-- Result 1 -->
|
||||
<g transform="translate(100, 250)">
|
||||
<rect width="600" height="90" rx="12" fill="white" stroke="#10B981" stroke-width="2" filter="drop-shadow(0 2px 12px rgba(16, 185, 129, 0.1))"/>
|
||||
|
||||
<!-- Document icon -->
|
||||
<g transform="translate(25, 20)">
|
||||
<rect width="50" height="50" rx="8" fill="#D1FAE5"/>
|
||||
<path d="M15 15 L35 15 M15 25 L35 25 M15 35 L25 35" stroke="#059669" stroke-width="2.5" stroke-linecap="round"/>
|
||||
</g>
|
||||
|
||||
<!-- Content -->
|
||||
<text x="95" y="35" font-family="PingFang SC, sans-serif" font-size="18" font-weight="600" fill="#065F46">RAG系统技术文档.pdf</text>
|
||||
<text x="95" y="57" font-family="PingFang SC, sans-serif" font-size="13" fill="#6B7280">详细介绍了检索增强生成的核心原理和实现方案...</text>
|
||||
<text x="95" y="75" font-family="PingFang SC, sans-serif" font-size="12" fill="#9CA3AF">3.2 MB • 127页 • 2024-01-20</text>
|
||||
</g>
|
||||
|
||||
<!-- Result 2 -->
|
||||
<g transform="translate(100, 360)">
|
||||
<rect width="600" height="90" rx="12" fill="white" stroke="#E5E7EB" stroke-width="1.5" filter="drop-shadow(0 2px 8px rgba(0, 0, 0, 0.05))"/>
|
||||
|
||||
<!-- Document icon -->
|
||||
<g transform="translate(25, 20)">
|
||||
<rect width="50" height="50" rx="8" fill="#DBEAFE"/>
|
||||
<path d="M15 15 L35 15 M15 25 L35 25 M15 35 L28 35" stroke="#1E40AF" stroke-width="2.5" stroke-linecap="round"/>
|
||||
</g>
|
||||
|
||||
<!-- Content -->
|
||||
<text x="95" y="35" font-family="PingFang SC, sans-serif" font-size="18" font-weight="600" fill="#1F2937">向量检索优化方案.docx</text>
|
||||
<text x="95" y="57" font-family="PingFang SC, sans-serif" font-size="13" fill="#6B7280">基于Embedding的语义检索技术实践与优化...</text>
|
||||
<text x="95" y="75" font-family="PingFang SC, sans-serif" font-size="12" fill="#9CA3AF">1.8 MB • 45页 • 2024-01-19</text>
|
||||
</g>
|
||||
|
||||
<!-- Result 3 -->
|
||||
<g transform="translate(100, 470)">
|
||||
<rect width="600" height="90" rx="12" fill="white" stroke="#E5E7EB" stroke-width="1.5" filter="drop-shadow(0 2px 8px rgba(0, 0, 0, 0.05))"/>
|
||||
|
||||
<!-- Image icon -->
|
||||
<g transform="translate(25, 20)">
|
||||
<rect width="50" height="50" rx="8" fill="#FEF3C7"/>
|
||||
<circle cx="20" cy="28" r="5" fill="#F59E0B"/>
|
||||
<path d="M12 42 L20 34 L28 42 L38 32" stroke="#F59E0B" stroke-width="2.5" fill="none" stroke-linecap="round"/>
|
||||
</g>
|
||||
|
||||
<!-- Content -->
|
||||
<text x="95" y="35" font-family="PingFang SC, sans-serif" font-size="18" font-weight="600" fill="#1F2937">知识图谱架构图.png</text>
|
||||
<text x="95" y="57" font-family="PingFang SC, sans-serif" font-size="13" fill="#6B7280">展示知识图谱的节点关系和查询路径...</text>
|
||||
<text x="95" y="75" font-family="PingFang SC, sans-serif" font-size="12" fill="#9CA3AF">1.2 MB • 1920×1080 • 2024-01-18</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,154 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
|
||||
<!-- Background - Same green gradient as screenshot-1 -->
|
||||
<defs>
|
||||
<linearGradient id="grad2" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" style="stop-color:#F0FDF4;stop-opacity:1" />
|
||||
<stop offset="100%" style="stop-color:#DCFCE7;stop-opacity:1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="800" height="600" fill="url(#grad2)"/>
|
||||
|
||||
<!-- Decorative circles -->
|
||||
<circle cx="120" cy="90" r="110" fill="#10B981" opacity="0.04"/>
|
||||
<circle cx="680" cy="510" r="130" fill="#10B981" opacity="0.04"/>
|
||||
|
||||
<!-- Title -->
|
||||
<text x="400" y="70" font-family="PingFang SC, sans-serif" font-size="36" font-weight="700" fill="#065F46" text-anchor="middle">混合检索策略</text>
|
||||
<text x="400" y="105" font-family="PingFang SC, sans-serif" font-size="16" fill="#059669" text-anchor="middle">BM25 关键词 + 向量语义 + 知识图谱</text>
|
||||
|
||||
<!-- Three retrieval methods -->
|
||||
<!-- BM25 -->
|
||||
<g transform="translate(80, 170)">
|
||||
<rect width="180" height="280" rx="12" fill="white" stroke="#F59E0B" stroke-width="2.5" filter="drop-shadow(0 4px 16px rgba(245, 158, 11, 0.15))"/>
|
||||
<rect width="180" height="50" rx="12" fill="#FEF3C7"/>
|
||||
<text x="90" y="33" font-family="PingFang SC, sans-serif" font-size="18" font-weight="700" fill="#92400E" text-anchor="middle">BM25</text>
|
||||
|
||||
<!-- Icon -->
|
||||
<g transform="translate(65, 70)">
|
||||
<circle cx="25" cy="25" r="20" fill="#FBBF24" opacity="0.2"/>
|
||||
<text x="25" y="33" font-family="Arial" font-size="24" font-weight="700" fill="#F59E0B" text-anchor="middle">K</text>
|
||||
</g>
|
||||
|
||||
<!-- Features -->
|
||||
<text x="90" y="135" font-family="PingFang SC, sans-serif" font-size="14" fill="#92400E" text-anchor="middle">关键词匹配</text>
|
||||
|
||||
<g transform="translate(20, 155)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#FEF3C7"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#78350F" text-anchor="middle">TF-IDF 权重</text>
|
||||
</g>
|
||||
|
||||
<g transform="translate(20, 195)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#FEF3C7"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#78350F" text-anchor="middle">词频统计</text>
|
||||
</g>
|
||||
|
||||
<g transform="translate(20, 235)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#FEF3C7"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#78350F" text-anchor="middle">精确匹配</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- Vector -->
|
||||
<g transform="translate(310, 170)">
|
||||
<rect width="180" height="280" rx="12" fill="white" stroke="#3B82F6" stroke-width="2.5" filter="drop-shadow(0 4px 16px rgba(59, 130, 246, 0.15))"/>
|
||||
<rect width="180" height="50" rx="12" fill="#DBEAFE"/>
|
||||
<text x="90" y="33" font-family="PingFang SC, sans-serif" font-size="18" font-weight="700" fill="#1E40AF" text-anchor="middle">向量检索</text>
|
||||
|
||||
<!-- Icon - Vector space -->
|
||||
<g transform="translate(65, 70)">
|
||||
<circle cx="25" cy="25" r="20" fill="#60A5FA" opacity="0.2"/>
|
||||
<circle cx="15" cy="20" r="3" fill="#1E40AF"/>
|
||||
<circle cx="25" cy="15" r="3" fill="#1E40AF"/>
|
||||
<circle cx="35" cy="20" r="3" fill="#1E40AF"/>
|
||||
<circle cx="20" cy="28" r="4" fill="#3B82F6"/>
|
||||
<circle cx="30" cy="28" r="4" fill="#3B82F6"/>
|
||||
<circle cx="15" cy="35" r="3" fill="#1E40AF"/>
|
||||
<circle cx="25" cy="38" r="3" fill="#1E40AF"/>
|
||||
<circle cx="35" cy="35" r="3" fill="#1E40AF"/>
|
||||
<!-- Connection lines -->
|
||||
<line x1="15" y1="20" x2="25" y2="15" stroke="#3B82F6" stroke-width="1" opacity="0.5"/>
|
||||
<line x1="25" y1="15" x2="35" y2="20" stroke="#3B82F6" stroke-width="1" opacity="0.5"/>
|
||||
<line x1="15" y1="20" x2="20" y2="28" stroke="#3B82F6" stroke-width="1" opacity="0.5"/>
|
||||
<line x1="35" y1="20" x2="30" y2="28" stroke="#3B82F6" stroke-width="1" opacity="0.5"/>
|
||||
<line x1="20" y1="28" x2="15" y2="35" stroke="#3B82F6" stroke-width="1" opacity="0.5"/>
|
||||
<line x1="30" y1="28" x2="35" y2="35" stroke="#3B82F6" stroke-width="1" opacity="0.5"/>
|
||||
</g>
|
||||
|
||||
<!-- Features -->
|
||||
<text x="90" y="135" font-family="PingFang SC, sans-serif" font-size="14" fill="#1E40AF" text-anchor="middle">语义理解</text>
|
||||
|
||||
<g transform="translate(20, 155)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#DBEAFE"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#1E3A8A" text-anchor="middle">Embedding</text>
|
||||
</g>
|
||||
|
||||
<g transform="translate(20, 195)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#DBEAFE"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#1E3A8A" text-anchor="middle">余弦相似度</text>
|
||||
</g>
|
||||
|
||||
<g transform="translate(20, 235)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#DBEAFE"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#1E3A8A" text-anchor="middle">ANN 检索</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- Knowledge Graph -->
|
||||
<g transform="translate(540, 170)">
|
||||
<rect width="180" height="280" rx="12" fill="white" stroke="#10B981" stroke-width="2.5" filter="drop-shadow(0 4px 16px rgba(16, 185, 129, 0.15))"/>
|
||||
<rect width="180" height="50" rx="12" fill="#DCFCE7"/>
|
||||
<text x="90" y="33" font-family="PingFang SC, sans-serif" font-size="18" font-weight="700" fill="#065F46" text-anchor="middle">知识图谱</text>
|
||||
|
||||
<!-- Icon - Graph nodes -->
|
||||
<g transform="translate(65, 70)">
|
||||
<circle cx="25" cy="25" r="20" fill="#34D399" opacity="0.2"/>
|
||||
<!-- Nodes -->
|
||||
<circle cx="15" cy="15" r="5" fill="#FFFFFF" stroke="#10B981" stroke-width="2"/>
|
||||
<circle cx="35" cy="15" r="5" fill="#FFFFFF" stroke="#10B981" stroke-width="2"/>
|
||||
<circle cx="25" cy="28" r="6" fill="#10B981" stroke="#065F46" stroke-width="2"/>
|
||||
<circle cx="15" cy="38" r="5" fill="#FFFFFF" stroke="#10B981" stroke-width="2"/>
|
||||
<circle cx="35" cy="38" r="5" fill="#FFFFFF" stroke="#10B981" stroke-width="2"/>
|
||||
<!-- Edges -->
|
||||
<line x1="15" y1="15" x2="25" y2="28" stroke="#10B981" stroke-width="2"/>
|
||||
<line x1="35" y1="15" x2="25" y2="28" stroke="#10B981" stroke-width="2"/>
|
||||
<line x1="25" y1="28" x2="15" y2="38" stroke="#10B981" stroke-width="2"/>
|
||||
<line x1="25" y1="28" x2="35" y2="38" stroke="#10B981" stroke-width="2"/>
|
||||
</g>
|
||||
|
||||
<!-- Features -->
|
||||
<text x="90" y="135" font-family="PingFang SC, sans-serif" font-size="14" fill="#065F46" text-anchor="middle">关系推理</text>
|
||||
|
||||
<g transform="translate(20, 155)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#DCFCE7"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#064E3B" text-anchor="middle">实体识别</text>
|
||||
</g>
|
||||
|
||||
<g transform="translate(20, 195)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#DCFCE7"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#064E3B" text-anchor="middle">路径查询</text>
|
||||
</g>
|
||||
|
||||
<g transform="translate(20, 235)">
|
||||
<rect x="0" y="0" width="140" height="30" rx="6" fill="#DCFCE7"/>
|
||||
<text x="70" y="20" font-family="PingFang SC, sans-serif" font-size="12" fill="#064E3B" text-anchor="middle">子图匹配</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- Arrows to fusion -->
|
||||
<path d="M170 460 L400 510" stroke="#9CA3AF" stroke-width="2.5" stroke-dasharray="5,3" marker-end="url(#arrowGray)"/>
|
||||
<path d="M400 460 L400 510" stroke="#9CA3AF" stroke-width="2.5" stroke-dasharray="5,3" marker-end="url(#arrowGray)"/>
|
||||
<path d="M630 460 L400 510" stroke="#9CA3AF" stroke-width="2.5" stroke-dasharray="5,3" marker-end="url(#arrowGray)"/>
|
||||
|
||||
<!-- Fusion result -->
|
||||
<g transform="translate(250, 520)">
|
||||
<rect width="300" height="50" rx="10" fill="#10B981" filter="drop-shadow(0 4px 16px rgba(16, 185, 129, 0.25))"/>
|
||||
<text x="150" y="32" font-family="PingFang SC, sans-serif" font-size="16" font-weight="700" fill="white" text-anchor="middle">融合排序 → 最优结果</text>
|
||||
</g>
|
||||
|
||||
<!-- Arrow marker -->
|
||||
<defs>
|
||||
<marker id="arrowGray" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
|
||||
<polygon points="0 0, 10 3, 0 6" fill="#9CA3AF"/>
|
||||
</marker>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.2 KiB |
@@ -0,0 +1,102 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 600">
|
||||
<!-- Background - Same green gradient -->
|
||||
<defs>
|
||||
<linearGradient id="grad3" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" style="stop-color:#F0FDF4;stop-opacity:1" />
|
||||
<stop offset="100%" style="stop-color:#DCFCE7;stop-opacity:1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="800" height="600" fill="url(#grad3)"/>
|
||||
|
||||
<!-- Decorative circles -->
|
||||
<circle cx="110" cy="85" r="105" fill="#10B981" opacity="0.04"/>
|
||||
<circle cx="690" cy="515" r="125" fill="#10B981" opacity="0.04"/>
|
||||
|
||||
<!-- Title -->
|
||||
<text x="400" y="70" font-family="PingFang SC, sans-serif" font-size="36" font-weight="700" fill="#065F46" text-anchor="middle">Agentic RAG</text>
|
||||
<text x="400" y="105" font-family="PingFang SC, sans-serif" font-size="16" fill="#059669" text-anchor="middle">基于 ReAct 范式的智能检索代理</text>
|
||||
|
||||
<!-- Query Input -->
|
||||
<g transform="translate(300, 140)">
|
||||
<rect width="200" height="50" rx="10" fill="white" stroke="#10B981" stroke-width="2" filter="drop-shadow(0 4px 16px rgba(16, 185, 129, 0.15))"/>
|
||||
<text x="100" y="32" font-family="PingFang SC, sans-serif" font-size="16" font-weight="600" fill="#065F46" text-anchor="middle">用户问题</text>
|
||||
</g>
|
||||
|
||||
<!-- Arrow down -->
|
||||
<path d="M400 200 L400 225" stroke="#059669" stroke-width="3" marker-end="url(#arrowGreen)"/>
|
||||
|
||||
<!-- ReAct Loop Container -->
|
||||
<g transform="translate(120, 235)">
|
||||
<rect width="560" height="240" rx="16" fill="white" stroke="#8B5CF6" stroke-width="3" stroke-dasharray="10,5" filter="drop-shadow(0 4px 20px rgba(139, 92, 246, 0.15))"/>
|
||||
<text x="280" y="30" font-family="PingFang SC, sans-serif" font-size="18" font-weight="700" fill="#5B21B6" text-anchor="middle">ReAct 循环</text>
|
||||
|
||||
<!-- Reasoning -->
|
||||
<g transform="translate(40, 55)">
|
||||
<rect width="220" height="75" rx="10" fill="#EDE9FE" stroke="#8B5CF6" stroke-width="2"/>
|
||||
<text x="110" y="25" font-family="PingFang SC, sans-serif" font-size="17" font-weight="700" fill="#5B21B6" text-anchor="middle">① Reasoning</text>
|
||||
<text x="110" y="45" font-family="PingFang SC, sans-serif" font-size="13" fill="#6B21A8" text-anchor="middle">分析问题</text>
|
||||
<text x="110" y="63" font-family="PingFang SC, sans-serif" font-size="13" fill="#6B21A8" text-anchor="middle">规划行动策略</text>
|
||||
</g>
|
||||
|
||||
<!-- Arrow to Tools -->
|
||||
<path d="M270 92 L290 92" stroke="#8B5CF6" stroke-width="2.5" marker-end="url(#arrowPurple)"/>
|
||||
|
||||
<!-- Acting with Tools -->
|
||||
<g transform="translate(300, 55)">
|
||||
<rect width="220" height="160" rx="10" fill="#FEF3C7" stroke="#F59E0B" stroke-width="2"/>
|
||||
<text x="110" y="25" font-family="PingFang SC, sans-serif" font-size="17" font-weight="700" fill="#92400E" text-anchor="middle">② Acting (Tools)</text>
|
||||
|
||||
<!-- Tool 1 -->
|
||||
<g transform="translate(20, 38)">
|
||||
<rect width="180" height="28" rx="6" fill="white" stroke="#F59E0B" stroke-width="1.5"/>
|
||||
<circle cx="14" cy="14" r="6" fill="#FBBF24"/>
|
||||
<text x="95" y="18" font-family="PingFang SC, sans-serif" font-size="12" fill="#78350F" text-anchor="middle">🔍 向量检索</text>
|
||||
</g>
|
||||
|
||||
<!-- Tool 2 -->
|
||||
<g transform="translate(20, 73)">
|
||||
<rect width="180" height="28" rx="6" fill="white" stroke="#F59E0B" stroke-width="1.5"/>
|
||||
<circle cx="14" cy="14" r="6" fill="#FBBF24"/>
|
||||
<text x="95" y="18" font-family="PingFang SC, sans-serif" font-size="12" fill="#78350F" text-anchor="middle">🔗 知识图谱</text>
|
||||
</g>
|
||||
|
||||
<!-- Tool 3 -->
|
||||
<g transform="translate(20, 108)">
|
||||
<rect width="180" height="28" rx="6" fill="white" stroke="#F59E0B" stroke-width="1.5"/>
|
||||
<circle cx="14" cy="14" r="6" fill="#FBBF24"/>
|
||||
<text x="95" y="18" font-family="PingFang SC, sans-serif" font-size="12" fill="#78350F" text-anchor="middle">📊 BM25检索</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- Arrow back to Reasoning (loop) -->
|
||||
<path d="M300 160 Q 280 195 150 160" stroke="#8B5CF6" stroke-width="2.5" stroke-dasharray="5,3" fill="none" marker-end="url(#arrowPurple)"/>
|
||||
<text x="220" y="200" font-family="PingFang SC, sans-serif" font-size="12" fill="#7C3AED" text-anchor="middle">迭代优化</text>
|
||||
</g>
|
||||
|
||||
<!-- Arrow down to result -->
|
||||
<path d="M400 485 L400 505" stroke="#059669" stroke-width="3" marker-end="url(#arrowGreen)"/>
|
||||
|
||||
<!-- Final Answer -->
|
||||
<g transform="translate(250, 515)">
|
||||
<rect width="300" height="50" rx="10" fill="#10B981" filter="drop-shadow(0 4px 16px rgba(16, 185, 129, 0.25))"/>
|
||||
<text x="150" y="32" font-family="PingFang SC, sans-serif" font-size="16" font-weight="700" fill="white" text-anchor="middle">③ 生成增强答案</text>
|
||||
</g>
|
||||
|
||||
<!-- Side annotation -->
|
||||
<g transform="translate(50, 320)">
|
||||
<text x="0" y="0" font-family="PingFang SC, sans-serif" font-size="13" font-weight="600" fill="#059669">特点:</text>
|
||||
<text x="0" y="22" font-family="PingFang SC, sans-serif" font-size="12" fill="#6B7280">• 自主推理</text>
|
||||
<text x="0" y="42" font-family="PingFang SC, sans-serif" font-size="12" fill="#6B7280">• 工具调用</text>
|
||||
<text x="0" y="62" font-family="PingFang SC, sans-serif" font-size="12" fill="#6B7280">• 动态迭代</text>
|
||||
</g>
|
||||
|
||||
<!-- Arrow markers -->
|
||||
<defs>
|
||||
<marker id="arrowGreen" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
|
||||
<polygon points="0 0, 10 3, 0 6" fill="#059669"/>
|
||||
</marker>
|
||||
<marker id="arrowPurple" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
|
||||
<polygon points="0 0, 10 3, 0 6" fill="#8B5CF6"/>
|
||||
</marker>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.17736 1.28207C9.32257 1.23367 9.4805 1.24024 9.6212 1.30054L18.3713 5.05054C18.5619 5.13222 18.6995 5.30316 18.7388 5.50681C18.778 5.71045 18.7136 5.9203 18.567 6.06694C18.5138 6.12012 18.4366 6.24314 18.3744 6.46076C18.3146 6.66994 18.2812 6.92361 18.2812 7.1875C18.2812 7.45139 18.3146 7.70506 18.3744 7.91424C18.4366 8.13186 18.5138 8.25487 18.567 8.30806C18.811 8.55214 18.811 8.94786 18.567 9.19194C18.5138 9.24512 18.4366 9.36814 18.3744 9.58576C18.3146 9.79494 18.2812 10.0486 18.2812 10.3125C18.2812 10.5764 18.3146 10.8301 18.3744 11.0392C18.4366 11.2569 18.5138 11.3799 18.567 11.4331C18.811 11.6771 18.811 12.0729 18.567 12.3169C18.5138 12.3701 18.4366 12.4931 18.3744 12.7108C18.3146 12.92 18.2812 13.1736 18.2812 13.4375C18.2812 13.7014 18.3146 13.955 18.3744 14.1642C18.4366 14.3819 18.5138 14.5049 18.567 14.558C18.709 14.7001 18.7741 14.9017 18.7419 15.1001C18.7097 15.2984 18.5843 15.4691 18.4045 15.559L12.1545 18.684C11.9886 18.767 11.7944 18.772 11.6245 18.6976L1.62449 14.3226C1.397 14.2231 1.25 13.9983 1.25 13.75V4.375C1.25 4.10599 1.42215 3.86715 1.67736 3.78207L9.17736 1.28207ZM2.5 5.33064L10.9868 9.04362C10.9627 9.10997 10.9413 9.1765 10.9225 9.24236C10.826 9.58006 10.7812 9.95139 10.7812 10.3125C10.7812 10.6736 10.826 11.0449 10.9225 11.3826C10.9694 11.5469 11.0321 11.7153 11.1153 11.875C11.0321 12.0347 10.9694 12.2031 10.9225 12.3674C10.826 12.705 10.7812 13.0764 10.7812 13.4375C10.7812 13.7986 10.826 14.17 10.9225 14.5076C10.9694 14.6719 11.0321 14.8403 11.1153 15C11.0321 15.1597 10.9694 15.3281 10.9225 15.4924C10.826 15.83 10.7812 16.2014 10.7812 16.5625C10.7812 16.6986 10.7876 16.8361 10.8007 16.9728L2.5 13.3413V5.33064ZM12.1275 17.3C12.1265 17.2964 12.1254 17.2929 12.1244 17.2892C12.0646 17.08 12.0312 16.8264 12.0312 16.5625C12.0312 16.2986 12.0646 16.045 12.1244 15.8358C12.1695 15.6779 12.2225 15.5697 12.2686 15.502L17.0432 13.1146C17.0351 13.2224 17.0312 13.3304 17.0312 13.4375C17.0312 13.7986 17.076 14.17 17.1725 14.5076C17.1944 14.5844 17.2198 14.662 17.249 14.7393L12.1275 17.3ZM17.249 11.6142L12.1275 14.175C12.1265 14.1714 12.1254 14.1679 12.1244 14.1642C12.0646 13.955 12.0312 13.7014 12.0312 13.4375C12.0312 13.1736 12.0646 12.92 12.1244 12.7108C12.1695 12.5529 12.2225 12.4447 12.2686 12.377L17.0432 9.98965C17.0351 10.0974 17.0312 10.2054 17.0312 10.3125C17.0312 10.6736 17.076 11.0449 17.1725 11.3826C17.1944 11.4594 17.2198 11.537 17.249 11.6142ZM17.249 8.48921L12.1275 11.05C12.1265 11.0464 12.1254 11.0428 12.1244 11.0392C12.0646 10.8301 12.0312 10.5764 12.0312 10.3125C12.0312 10.0486 12.0646 9.79494 12.1244 9.58576C12.1695 9.42785 12.2225 9.31975 12.2686 9.252L17.0432 6.86465C17.0351 6.9724 17.0312 7.0804 17.0312 7.1875C17.0312 7.54861 17.076 7.91994 17.1725 8.25764C17.1944 8.33437 17.2198 8.412 17.249 8.48921ZM16.6402 5.66864L9.34721 2.54307L3.61469 4.45391L11.8573 8.06006L16.6402 5.66864Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.3"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -1,3 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" class="gh6beppe9__design-iconfont" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 3C2 2.17157 2.67157 1.5 3.5 1.5H12C12.2761 1.5 12.5 1.72386 12.5 2V11C12.5 11.2761 12.2761 11.5 12 11.5H4C3.44772 11.5 3 11.9477 3 12.5C3 13.0523 3.44772 13.5 4 13.5H13V2.5H14V14C14 14.2761 13.7761 14.5 13.5 14.5H4C2.89543 14.5 2 13.6046 2 12.5V3ZM3 10.7676C3.29417 10.5974 3.63571 10.5 4 10.5H11.5V2.5H3.5C3.22386 2.5 3 2.72386 3 3V10.7676ZM12.5 13H3.5V12H12.5V13Z" fill="#32CE3F"></path>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 16 16" width="128" height="128">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 3C2 2.17157 2.67157 1.5 3.5 1.5H12C12.2761 1.5 12.5 1.72386 12.5 2V11C12.5 11.2761 12.2761 11.5 12 11.5H4C3.44772 11.5 3 11.9477 3 12.5C3 13.0523 3.44772 13.5 4 13.5H13V2.5H14V14C14 14.2761 13.7761 14.5 13.5 14.5H4C2.89543 14.5 2 13.6046 2 12.5V3ZM3 10.7676C3.29417 10.5974 3.63571 10.5 4 10.5H11.5V2.5H3.5C3.22386 2.5 3 2.72386 3 3V10.7676ZM12.5 13H3.5V12H12.5V13Z" fill="#07C05F" stroke="#07C05F" stroke-width="0.3"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 578 B |
@@ -1,13 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, defineEmits, onMounted, defineProps, computed, watch, nextTick, h } from "vue";
|
||||
import { ref, defineEmits, onMounted, onUnmounted, defineProps, computed, watch, nextTick, h } from "vue";
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { onBeforeRouteUpdate } from 'vue-router';
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
import { useUIStore } from '@/stores/ui';
|
||||
import { listKnowledgeBases } from '@/api/knowledge-base';
|
||||
import { listKnowledgeBases, getKnowledgeBaseById } from '@/api/knowledge-base';
|
||||
import { stopSession } from '@/api/chat';
|
||||
import KnowledgeBaseSelector from './KnowledgeBaseSelector.vue';
|
||||
import { getModel, type ModelConfig } from '@/api/model';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -41,6 +42,14 @@ const selectedKbs = computed(() => {
|
||||
return knowledgeBases.value.filter(kb => selectedKbIds.value.includes(kb.id));
|
||||
});
|
||||
|
||||
// 模型相关状态
|
||||
const availableModels = ref<ModelConfig[]>([]);
|
||||
const selectedModelId = ref<string>('');
|
||||
const thinkingModelName = ref<string>('');
|
||||
const showModelSelector = ref(false);
|
||||
const modelButtonRef = ref<HTMLElement>();
|
||||
const modelDropdownStyle = ref<Record<string, string>>({});
|
||||
|
||||
// 显示的知识库标签(最多显示2个)
|
||||
const displayedKbs = computed(() => selectedKbs.value.slice(0, 2));
|
||||
const remainingCount = computed(() => Math.max(0, selectedKbs.value.length - 2));
|
||||
@@ -50,16 +59,140 @@ const loadKnowledgeBases = async () => {
|
||||
try {
|
||||
const response: any = await listKnowledgeBases();
|
||||
if (response.data && Array.isArray(response.data)) {
|
||||
knowledgeBases.value = response.data.filter((kb: any) =>
|
||||
const validKbs = response.data.filter((kb: any) =>
|
||||
kb.embedding_model_id && kb.embedding_model_id !== '' &&
|
||||
kb.summary_model_id && kb.summary_model_id !== ''
|
||||
);
|
||||
knowledgeBases.value = validKbs;
|
||||
|
||||
// 清理无效的知识库ID(已删除或不存在于有效知识库列表中的)
|
||||
const validKbIds = new Set(validKbs.map((kb: any) => kb.id));
|
||||
const currentSelectedIds = settingsStore.settings.selectedKnowledgeBases || [];
|
||||
const validSelectedIds = currentSelectedIds.filter((id: string) => validKbIds.has(id));
|
||||
|
||||
// 如果有无效的ID,更新store
|
||||
if (validSelectedIds.length !== currentSelectedIds.length) {
|
||||
settingsStore.selectKnowledgeBases(validSelectedIds);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load knowledge bases:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 解析模型参数大小 (e.g., "7B", "13B", "70B" -> 7, 13, 70)
|
||||
const parseParameterSize = (paramSize: string | undefined): number => {
|
||||
if (!paramSize) return 0;
|
||||
const match = paramSize.match(/(\d+\.?\d*)/);
|
||||
return match ? parseFloat(match[1]) : 0;
|
||||
};
|
||||
|
||||
// 加载并选择模型
|
||||
const loadModelsFromKnowledgeBases = async () => {
|
||||
if (selectedKbIds.value.length === 0) {
|
||||
availableModels.value = [];
|
||||
selectedModelId.value = '';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 获取所有选中知识库的 summary_model_id
|
||||
const modelIds = new Set<string>();
|
||||
for (const kbId of selectedKbIds.value) {
|
||||
try {
|
||||
const kb: any = await getKnowledgeBaseById(kbId);
|
||||
if (kb.data?.summary_model_id) {
|
||||
modelIds.add(kb.data.summary_model_id);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to fetch KB ${kbId}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有模型的详细信息
|
||||
const models: ModelConfig[] = [];
|
||||
for (const modelId of Array.from(modelIds)) {
|
||||
try {
|
||||
const model = await getModel(modelId);
|
||||
models.push(model);
|
||||
} catch (error) {
|
||||
console.error(`Failed to fetch model ${modelId}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
availableModels.value = models;
|
||||
|
||||
// 应用优先级选择算法
|
||||
if (models.length > 0) {
|
||||
selectModelByPriority(models);
|
||||
} else {
|
||||
selectedModelId.value = '';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load models from knowledge bases:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 根据优先级选择模型
|
||||
const selectModelByPriority = (models: ModelConfig[]) => {
|
||||
// 1. 优先选择远程模型,按创建时间降序
|
||||
const remoteModels = models
|
||||
.filter(m => m.source === 'remote')
|
||||
.sort((a, b) => {
|
||||
const timeA = new Date(a.created_at || 0).getTime();
|
||||
const timeB = new Date(b.created_at || 0).getTime();
|
||||
return timeB - timeA;
|
||||
});
|
||||
|
||||
if (remoteModels.length > 0) {
|
||||
selectedModelId.value = remoteModels[0].id || '';
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 否则选择 Ollama 模型,按参数大小降序
|
||||
const ollamaModels = models
|
||||
.filter(m => m.source === 'local')
|
||||
.sort((a, b) => {
|
||||
const sizeA = parseParameterSize(a.parameters?.parameter_size);
|
||||
const sizeB = parseParameterSize(b.parameters?.parameter_size);
|
||||
return sizeB - sizeA;
|
||||
});
|
||||
|
||||
if (ollamaModels.length > 0) {
|
||||
selectedModelId.value = ollamaModels[0].id || '';
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 如果都没有,选择第一个
|
||||
selectedModelId.value = models[0]?.id || '';
|
||||
};
|
||||
|
||||
// 获取 Thinking 模型名称(Agent 模式)
|
||||
const loadThinkingModelName = async () => {
|
||||
const thinkingModelId = settingsStore.agentConfig.thinkingModelId;
|
||||
if (thinkingModelId) {
|
||||
try {
|
||||
const model = await getModel(thinkingModelId);
|
||||
thinkingModelName.value = model.name || thinkingModelId;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch thinking model:', error);
|
||||
thinkingModelName.value = thinkingModelId;
|
||||
}
|
||||
} else {
|
||||
thinkingModelName.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
// 计算当前选中的模型
|
||||
const selectedModel = computed(() => {
|
||||
return availableModels.value.find(m => m.id === selectedModelId.value);
|
||||
});
|
||||
|
||||
// 关闭模型选择器(点击外部)
|
||||
const closeModelSelector = () => {
|
||||
showModelSelector.value = false;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadKnowledgeBases();
|
||||
|
||||
@@ -68,6 +201,26 @@ onMounted(() => {
|
||||
if (kbId && !selectedKbIds.value.includes(kbId)) {
|
||||
settingsStore.addKnowledgeBase(kbId);
|
||||
}
|
||||
|
||||
// 加载模型
|
||||
if (isAgentEnabled.value) {
|
||||
loadThinkingModelName();
|
||||
} else {
|
||||
loadModelsFromKnowledgeBases();
|
||||
}
|
||||
|
||||
// 监听点击外部关闭下拉菜单
|
||||
document.addEventListener('click', closeModelSelector);
|
||||
// 监听窗口大小变化,重新计算位置
|
||||
window.addEventListener('resize', () => {
|
||||
if (showModelSelector.value) {
|
||||
updateModelDropdownPosition();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener('click', closeModelSelector);
|
||||
});
|
||||
|
||||
// 监听路由变化
|
||||
@@ -77,6 +230,29 @@ watch(() => route.params.kbId, (newKbId) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 监听知识库选择变化,重新加载模型
|
||||
watch(selectedKbIds, () => {
|
||||
if (!isAgentEnabled.value) {
|
||||
loadModelsFromKnowledgeBases();
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
// 监听 Agent 模式变化
|
||||
watch(isAgentEnabled, (newVal) => {
|
||||
if (newVal) {
|
||||
loadThinkingModelName();
|
||||
} else {
|
||||
loadModelsFromKnowledgeBases();
|
||||
}
|
||||
});
|
||||
|
||||
// 监听 Thinking 模型变化
|
||||
watch(() => settingsStore.agentConfig.thinkingModelId, () => {
|
||||
if (isAgentEnabled.value) {
|
||||
loadThinkingModelName();
|
||||
}
|
||||
});
|
||||
|
||||
const emit = defineEmits(['send-msg', 'stop-generation']);
|
||||
|
||||
const createSession = (val: string) => {
|
||||
@@ -91,10 +267,65 @@ const createSession = (val: string) => {
|
||||
if (props.isReplying) {
|
||||
return MessagePlugin.error("正在回复中,请稍后再试!");
|
||||
}
|
||||
emit('send-msg', val);
|
||||
emit('send-msg', val, selectedModelId.value);
|
||||
clearvalue();
|
||||
}
|
||||
|
||||
// 计算模型下拉菜单位置
|
||||
const updateModelDropdownPosition = () => {
|
||||
const anchor = modelButtonRef.value;
|
||||
|
||||
if (!anchor) {
|
||||
modelDropdownStyle.value = {
|
||||
position: 'fixed',
|
||||
top: '50%',
|
||||
left: '50%',
|
||||
transform: 'translate(-50%, -50%)'
|
||||
};
|
||||
return;
|
||||
}
|
||||
|
||||
const rect = anchor.getBoundingClientRect();
|
||||
const dropdownWidth = 250;
|
||||
const offsetY = 8;
|
||||
|
||||
// 计算位置:默认在按钮下方
|
||||
let top = rect.bottom + offsetY;
|
||||
let left = rect.left;
|
||||
|
||||
// 检查右侧边界
|
||||
if (left + dropdownWidth > window.innerWidth) {
|
||||
left = window.innerWidth - dropdownWidth - 10;
|
||||
}
|
||||
|
||||
// 检查下方空间
|
||||
const dropdownMaxHeight = 400;
|
||||
if (top + dropdownMaxHeight > window.innerHeight) {
|
||||
// 如果下方空间不足,显示在按钮上方
|
||||
top = rect.top - dropdownMaxHeight - offsetY;
|
||||
if (top < 10) {
|
||||
// 如果上方也不够,显示在屏幕中间
|
||||
top = 10;
|
||||
}
|
||||
}
|
||||
|
||||
modelDropdownStyle.value = {
|
||||
position: 'fixed',
|
||||
top: `${Math.round(top)}px`,
|
||||
left: `${Math.round(left)}px`,
|
||||
width: `${dropdownWidth}px`
|
||||
};
|
||||
};
|
||||
|
||||
const toggleModelSelector = () => {
|
||||
showModelSelector.value = !showModelSelector.value;
|
||||
if (showModelSelector.value) {
|
||||
nextTick(() => {
|
||||
updateModelDropdownPosition();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const clearvalue = () => {
|
||||
query.value = "";
|
||||
}
|
||||
@@ -281,6 +512,73 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
+{{ remainingCount }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 模型显示 -->
|
||||
<div v-if="selectedKbIds.length > 0" class="model-display">
|
||||
<!-- Agent 模式:只读显示 Thinking 模型 -->
|
||||
<div v-if="isAgentEnabled" class="model-badge">
|
||||
<span class="model-label">Thinking:</span>
|
||||
<span class="model-name">{{ thinkingModelName || '未配置' }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 非 Agent 模式:可选择的模型下拉 -->
|
||||
<div
|
||||
v-else
|
||||
ref="modelButtonRef"
|
||||
class="control-btn model-btn"
|
||||
:class="{ 'active': selectedModel }"
|
||||
@click.stop="toggleModelSelector"
|
||||
>
|
||||
<span class="model-btn-text">
|
||||
{{ selectedModel ? selectedModel.name : '模型' }}
|
||||
</span>
|
||||
<svg
|
||||
width="12"
|
||||
height="12"
|
||||
viewBox="0 0 12 12"
|
||||
fill="currentColor"
|
||||
class="dropdown-arrow"
|
||||
:class="{ 'rotate': showModelSelector }"
|
||||
>
|
||||
<path d="M2.5 4.5L6 8L9.5 4.5H2.5Z"/>
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<!-- 模型选择下拉菜单 -->
|
||||
<Teleport to="body">
|
||||
<div v-if="showModelSelector && !isAgentEnabled" class="model-selector-overlay">
|
||||
<div
|
||||
class="model-selector-dropdown"
|
||||
:style="modelDropdownStyle"
|
||||
@click.stop
|
||||
>
|
||||
<div class="model-selector-content">
|
||||
<div
|
||||
v-for="model in availableModels"
|
||||
:key="model.id"
|
||||
class="model-option"
|
||||
:class="{ 'selected': model.id === selectedModelId }"
|
||||
@click="selectedModelId = model.id || ''; showModelSelector = false"
|
||||
>
|
||||
<div class="model-option-main">
|
||||
<span class="model-option-name">{{ model.name }}</span>
|
||||
<span v-if="model.source === 'remote'" class="model-badge-remote">远程</span>
|
||||
<span v-else-if="model.parameters?.parameter_size" class="model-badge-local">
|
||||
{{ model.parameters.parameter_size }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="model.description" class="model-option-desc">
|
||||
{{ model.description }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="availableModels.length === 0" class="model-option empty">
|
||||
暂无可用模型
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧控制按钮组 -->
|
||||
@@ -665,4 +963,165 @@ const getImgSrc = (url: string) => {
|
||||
height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 模型显示样式 */
|
||||
.model-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 8px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.model-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 10px;
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
border-radius: 6px;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.model-label {
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.model-name {
|
||||
color: #07C05F;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.model-btn {
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
min-width: auto;
|
||||
|
||||
&.active {
|
||||
background: rgba(7, 192, 95, 0.1);
|
||||
color: #07C05F;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.model-btn-text {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
max-width: 150px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.model-btn.active .model-btn-text {
|
||||
color: #07C05F;
|
||||
}
|
||||
|
||||
/* 模型选择下拉菜单 */
|
||||
.model-selector-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 9998;
|
||||
}
|
||||
|
||||
.model-selector-dropdown {
|
||||
z-index: 9999;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
max-width: 350px;
|
||||
max-height: 400px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.model-selector-content {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.model-option {
|
||||
padding: 12px 16px;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
|
||||
.model-option-name {
|
||||
color: #07C05F;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
&.empty {
|
||||
color: #999;
|
||||
cursor: default;
|
||||
text-align: center;
|
||||
|
||||
&:hover {
|
||||
background: white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.model-option-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.model-option-name {
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.model-option-desc {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.model-badge-remote,
|
||||
.model-badge-local {
|
||||
display: inline-block;
|
||||
padding: 2px 6px;
|
||||
font-size: 11px;
|
||||
border-radius: 3px;
|
||||
font-weight: 500;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.model-badge-remote {
|
||||
background: rgba(7, 192, 95, 0.1);
|
||||
color: #07C05F;
|
||||
}
|
||||
|
||||
.model-badge-local {
|
||||
background: rgba(82, 196, 26, 0.1);
|
||||
color: #52c41a;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -115,7 +115,7 @@ export interface ThinkingData {
|
||||
export interface PlanStep {
|
||||
id: string;
|
||||
description: string;
|
||||
tools_to_use?: string;
|
||||
tools_to_use?: string[]; // Changed from string to array
|
||||
status: 'pending' | 'in_progress' | 'completed' | 'skipped';
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<SearchResults
|
||||
v-if="displayType === 'search_results'"
|
||||
:data="toolData as SearchResultsData"
|
||||
:arguments="toolArguments"
|
||||
/>
|
||||
|
||||
<!-- Chunk Detail -->
|
||||
@@ -90,6 +91,7 @@ interface Props {
|
||||
displayType?: DisplayType;
|
||||
toolData?: Record<string, any>;
|
||||
output?: string;
|
||||
arguments?: Record<string, any>;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
@@ -97,6 +99,7 @@ const props = defineProps<Props>();
|
||||
const displayType = computed(() => props.displayType);
|
||||
const toolData = computed(() => props.toolData || {});
|
||||
const output = computed(() => props.output || '');
|
||||
const toolArguments = computed(() => props.arguments || {});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
<t-popup overlayClassName="refer-to-layer" placement="bottom-left" width="400" :showArrow="false"
|
||||
trigger="click">
|
||||
<template #content>
|
||||
<div class="doc_content">
|
||||
<div v-html="safeProcessContent(item.content)"></div>
|
||||
</div>
|
||||
<ContentPopup :content="safeProcessContent(item.content)" :is-html="true" />
|
||||
</template>
|
||||
<span class="doc">
|
||||
{{ session.knowledge_references.length < 2 ? item.knowledge_title : `${index +
|
||||
@@ -29,6 +27,7 @@
|
||||
<script setup>
|
||||
import { onMounted, defineProps, computed, ref, reactive } from "vue";
|
||||
import { sanitizeHTML } from '@/utils/security';
|
||||
import ContentPopup from './tool-results/ContentPopup.vue';
|
||||
const props = defineProps({
|
||||
// 必填项
|
||||
content: {
|
||||
@@ -149,5 +148,15 @@ const safeProcessContent = (content) => {
|
||||
<style>
|
||||
.refer-to-layer {
|
||||
width: 400px;
|
||||
max-width: 500px;
|
||||
|
||||
.t-popup__content {
|
||||
max-height: 400px;
|
||||
max-width: 500px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<div class="popup-content">
|
||||
<div class="popup-content-wrapper">
|
||||
<div v-if="content" class="full-content" :class="{ 'html-content': isHtml }">
|
||||
<div v-if="isHtml" v-html="processedContent"></div>
|
||||
<template v-else>{{ content }}</template>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="hasInfo" class="info-section">
|
||||
<div v-if="chunkId" class="info-field">
|
||||
<span class="field-label">片段ID:</span>
|
||||
<span class="field-value"><code>{{ chunkId }}</code></span>
|
||||
</div>
|
||||
<div v-if="knowledgeId" class="info-field">
|
||||
<span class="field-label">文档ID:</span>
|
||||
<span class="field-value"><code>{{ knowledgeId }}</code></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { sanitizeHTML } from '@/utils/security';
|
||||
|
||||
interface Props {
|
||||
content?: string;
|
||||
chunkId?: string;
|
||||
knowledgeId?: string;
|
||||
isHtml?: boolean; // 是否以 HTML 格式显示内容
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const hasInfo = computed(() => {
|
||||
return !!(props.chunkId || props.knowledgeId);
|
||||
});
|
||||
|
||||
// 处理 HTML 内容
|
||||
const processedContent = computed(() => {
|
||||
if (!props.content) return '';
|
||||
if (props.isHtml) {
|
||||
return sanitizeHTML(props.content);
|
||||
}
|
||||
return props.content;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.popup-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 400px;
|
||||
max-width: 500px;
|
||||
border: 1px solid #07C05F;
|
||||
border-radius: 4px;
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
overflow: hidden;
|
||||
|
||||
.popup-content-wrapper {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 12px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.full-content {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
|
||||
&.html-content {
|
||||
white-space: normal;
|
||||
|
||||
:deep(p) {
|
||||
margin: 8px 0;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
:deep(br) {
|
||||
line-height: 1.8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.info-section {
|
||||
flex-shrink: 0;
|
||||
padding: 8px 12px;
|
||||
border-top: 1px solid #e7e7e7;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.info-field {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
font-size: 11px;
|
||||
|
||||
.field-label {
|
||||
color: #8b8b8b;
|
||||
min-width: 60px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.field-value {
|
||||
color: #666;
|
||||
flex: 1;
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 10px;
|
||||
background: #f0f0f0;
|
||||
padding: 1px 4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
<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 v-for="(step, index) in data.steps" :key="step.id || index" class="step-item" :class="`status-${step.status}`">
|
||||
<div class="step-checkbox" :class="{ 'checked': step.status === 'completed', 'in-progress': step.status === 'in_progress' }">
|
||||
<svg v-if="step.status === 'completed'" width="16" height="16" viewBox="0 0 16 16" fill="none">
|
||||
<rect x="2" y="2" width="12" height="12" rx="2" fill="#07C05F"/>
|
||||
<path d="M5 8L7 10L11 6" stroke="#fff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
<svg v-else width="16" height="16" viewBox="0 0 16 16" fill="none">
|
||||
<rect x="2" y="2" width="12" height="12" rx="2" stroke="#d1d5db" stroke-width="1.5" fill="none"/>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="step-description" :class="{ 'completed': step.status === 'completed' }">
|
||||
{{ step.description }}
|
||||
<span v-if="step.status === 'in_progress'" class="sparkle">✨</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,7 +25,6 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import type { PlanData } from '@/types/tool-results';
|
||||
|
||||
interface Props {
|
||||
@@ -38,139 +32,95 @@ interface Props {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
color: #666;
|
||||
background: transparent;
|
||||
padding: 8px 0 8px 12px;
|
||||
margin: 0;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.plan-steps {
|
||||
.steps-header {
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
margin-bottom: 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.step-item {
|
||||
margin-bottom: 12px;
|
||||
padding: 10px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e5e7eb;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding: 2px 0;
|
||||
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;
|
||||
.step-description {
|
||||
color: #333;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.step-checkbox {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
flex-shrink: 0;
|
||||
margin-top: 1px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&.checked {
|
||||
svg {
|
||||
rect {
|
||||
fill: #07C05F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.status-completed {
|
||||
color: #10b981;
|
||||
}
|
||||
|
||||
&.status-skipped {
|
||||
color: #9ca3af;
|
||||
&.in-progress {
|
||||
svg {
|
||||
rect {
|
||||
stroke: #07C05F;
|
||||
stroke-width: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.step-description {
|
||||
flex: 1;
|
||||
color: #1f2937;
|
||||
color: #666;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.step-tools {
|
||||
margin-top: 6px;
|
||||
padding-left: 26px;
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
font-size: 13px;
|
||||
|
||||
.tools-label {
|
||||
font-weight: 500;
|
||||
&.completed {
|
||||
text-decoration: line-through;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.sparkle {
|
||||
margin-left: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.no-steps {
|
||||
padding: 16px;
|
||||
padding: 8px 12px;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-style: italic;
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -1,46 +1,32 @@
|
||||
<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"
|
||||
class="result-item"
|
||||
>
|
||||
<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>
|
||||
<t-popup
|
||||
:overlayClassName="`chunk-popup-${chunk.chunk_id}`"
|
||||
placement="bottom-left"
|
||||
width="400"
|
||||
:showArrow="false"
|
||||
trigger="click"
|
||||
destroy-on-close
|
||||
>
|
||||
<template #content>
|
||||
<ContentPopup
|
||||
:content="chunk.content"
|
||||
:chunk-id="chunk.chunk_id"
|
||||
/>
|
||||
</template>
|
||||
<div class="result-header">
|
||||
<div class="result-title">
|
||||
<span class="chunk-index">片段 #{{ chunk.index }}</span>
|
||||
<span class="chunk-position">(位置: {{ chunk.chunk_index }})</span>
|
||||
</div>
|
||||
</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>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -53,29 +39,12 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, defineProps, computed } from 'vue';
|
||||
import type { RelatedChunksData } from '@/types/tool-results';
|
||||
import ContentPopup from './ContentPopup.vue';
|
||||
|
||||
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>
|
||||
@@ -84,26 +53,96 @@ const toggleChunk = (chunkId: string) => {
|
||||
.related-chunks {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
gap: 8px;
|
||||
padding: 0 0 0 12px;
|
||||
|
||||
.info-section {
|
||||
margin-bottom: 8px;
|
||||
padding: 0;
|
||||
|
||||
.info-field {
|
||||
font-size: 11px;
|
||||
margin-bottom: 4px;
|
||||
|
||||
.field-label {
|
||||
font-size: 11px;
|
||||
color: #8b8b8b;
|
||||
min-width: 70px;
|
||||
}
|
||||
|
||||
.field-value {
|
||||
font-size: 11px;
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.chunks-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.result-header {
|
||||
padding: 4px 0;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
&:hover {
|
||||
color: #07c05f;
|
||||
}
|
||||
}
|
||||
|
||||
.result-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.chunk-index {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chunk-position {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #8b8b8b;
|
||||
}
|
||||
|
||||
|
||||
// Popup overlay styles
|
||||
:deep([class*="chunk-popup-"]) {
|
||||
.t-popup__content {
|
||||
max-height: 400px;
|
||||
max-width: 500px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
|
||||
@@ -1,59 +1,37 @@
|
||||
<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"
|
||||
class="result-item"
|
||||
>
|
||||
<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>
|
||||
<t-popup
|
||||
:overlayClassName="`result-popup-${result.chunk_id}`"
|
||||
placement="bottom-left"
|
||||
width="400"
|
||||
:showArrow="false"
|
||||
trigger="click"
|
||||
destroy-on-close
|
||||
>
|
||||
<template #content>
|
||||
<ContentPopup
|
||||
:content="result.content"
|
||||
:chunk-id="result.chunk_id"
|
||||
:knowledge-id="result.knowledge_id"
|
||||
/>
|
||||
</template>
|
||||
<div class="result-header">
|
||||
<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>
|
||||
</div>
|
||||
</t-popup>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -68,24 +46,55 @@
|
||||
import { ref, defineProps, computed } from 'vue';
|
||||
import type { SearchResultsData, SearchResultItem, RelevanceLevel } from '@/types/tool-results';
|
||||
import { getMatchTypeIcon } from '@/utils/tool-icons';
|
||||
import ContentPopup from './ContentPopup.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
data: SearchResultsData;
|
||||
arguments?: Record<string, any> | string;
|
||||
}>();
|
||||
|
||||
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);
|
||||
// Parse arguments if it's a string
|
||||
const parsedArguments = computed(() => {
|
||||
const args = props.arguments;
|
||||
if (!args) return null;
|
||||
|
||||
// If it's already an object, return it
|
||||
if (typeof args === 'object' && !Array.isArray(args)) {
|
||||
return args;
|
||||
}
|
||||
};
|
||||
|
||||
// If it's a string, try to parse it
|
||||
if (typeof args === 'string') {
|
||||
try {
|
||||
return JSON.parse(args);
|
||||
} catch (e) {
|
||||
console.warn('Failed to parse arguments:', e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
// Check if there are search parameters to display (excluding query parameters which are in title)
|
||||
const hasSearchParams = computed(() => {
|
||||
const args = parsedArguments.value;
|
||||
if (!args || typeof args !== 'object') return false;
|
||||
|
||||
return !!(
|
||||
(Array.isArray(args.knowledge_base_ids) && args.knowledge_base_ids.length > 0) ||
|
||||
args.top_k || args.vector_threshold || args.keyword_threshold || args.min_score);
|
||||
});
|
||||
|
||||
const hasOtherParams = computed(() => {
|
||||
const args = parsedArguments.value;
|
||||
if (!args || typeof args !== 'object') return false;
|
||||
return !!(args.top_k || args.vector_threshold || args.keyword_threshold || args.min_score);
|
||||
});
|
||||
|
||||
|
||||
const getRelevanceClass = (level: RelevanceLevel): string => {
|
||||
const classMap: Record<RelevanceLevel, string> = {
|
||||
@@ -104,7 +113,85 @@ const getRelevanceClass = (level: RelevanceLevel): string => {
|
||||
.search-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 0 0 0 12px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.search-params {
|
||||
padding: 10px 12px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e7e7e7;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.params-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.param-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
|
||||
.param-label {
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
min-width: 75px;
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.param-value {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
line-height: 1.5;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
.params-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid #e7e7e7;
|
||||
|
||||
.param-meta-item {
|
||||
font-size: 11px;
|
||||
color: #666;
|
||||
background: #ffffff;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e7e7e7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.stats-card {
|
||||
padding: 8px 12px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e7e7e7;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
|
||||
.stats-label {
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.stats-item-inline {
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
.results-list {
|
||||
@@ -113,30 +200,115 @@ const getRelevanceClass = (level: RelevanceLevel): string => {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.result-header {
|
||||
padding: 4px 0;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
&:hover {
|
||||
color: #07c05f;
|
||||
}
|
||||
}
|
||||
|
||||
.result-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.result-index {
|
||||
font-size: 13px;
|
||||
font-size: 11px;
|
||||
color: #8b8b8b;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.relevance-badge {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
padding: 2px 6px;
|
||||
}
|
||||
|
||||
.knowledge-title {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
font-weight: 500;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.score {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
font-weight: 500;
|
||||
|
||||
// Popup overlay styles
|
||||
:deep([class*="result-popup-"]) {
|
||||
.t-popup__content {
|
||||
max-height: 400px;
|
||||
max-width: 500px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-top: 8px;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.full-content {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.8;
|
||||
padding: 12px;
|
||||
background: #ffffff;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e7e7e7;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.info-field {
|
||||
font-size: 11px;
|
||||
margin-bottom: 3px;
|
||||
|
||||
.field-label {
|
||||
min-width: 60px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
font-size: 10px;
|
||||
background: #f0f0f0;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
padding: 1px 4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
@@ -70,16 +70,17 @@
|
||||
|
||||
// Result card
|
||||
.result-card {
|
||||
background: @card-bg;
|
||||
background: #ffffff;
|
||||
border: 1px solid @card-border;
|
||||
border-radius: @card-radius;
|
||||
margin-bottom: 8px;
|
||||
margin-bottom: 0;
|
||||
overflow: hidden;
|
||||
transition: all @transition-time ease;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||
|
||||
&:hover {
|
||||
border-color: @card-hover-border;
|
||||
box-shadow: @card-shadow-hover;
|
||||
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.12);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,10 +92,16 @@
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.05);
|
||||
}
|
||||
|
||||
* {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.result-title {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</div>
|
||||
<div style="min-height: 115px; margin: 16px auto 4px;width: 100%;max-width: 800px;">
|
||||
<InputField
|
||||
@send-msg="sendMsg"
|
||||
@send-msg="(query, modelId) => sendMsg(query, modelId)"
|
||||
@stop-generation="handleStopGeneration"
|
||||
:isReplying="isReplying"
|
||||
:sessionId="session_id"
|
||||
@@ -259,7 +259,7 @@ const handleStopGeneration = () => {
|
||||
// API 调用成功后,后端的 stop 事件会清空它
|
||||
};
|
||||
|
||||
const sendMsg = async (value) => {
|
||||
const sendMsg = async (value, modelId = '') => {
|
||||
userquery.value = value;
|
||||
isReplying.value = true;
|
||||
loading.value = true;
|
||||
@@ -291,6 +291,7 @@ const sendMsg = async (value) => {
|
||||
session_id: session_id.value,
|
||||
knowledge_base_ids: kbIds,
|
||||
agent_enabled: agentEnabled,
|
||||
summary_model_id: modelId,
|
||||
query: value,
|
||||
method: 'POST',
|
||||
url: endpoint
|
||||
@@ -431,7 +432,7 @@ onChunk((data) => {
|
||||
})
|
||||
// 处理 Agent 流式数据 (Cursor-style UI)
|
||||
const handleAgentChunk = (data) => {
|
||||
const message = messagesList.findLast((item) => item.request_id === data.id || item.id === data.id);
|
||||
let message = messagesList.findLast((item) => item.request_id === data.id || item.id === data.id);
|
||||
|
||||
if (!message) {
|
||||
// 创建新的 Assistant 消息 - 此时开始显示内容,关闭 loading
|
||||
@@ -450,7 +451,8 @@ const handleAgentChunk = (data) => {
|
||||
messagesList.push(newMsg);
|
||||
loading.value = false; // 消息已创建,关闭 loading
|
||||
scrollToBottom();
|
||||
return;
|
||||
// Don't return - continue to process the current event data
|
||||
message = newMsg;
|
||||
}
|
||||
|
||||
message.isAgentMode = true;
|
||||
|
||||