import { useState } from "react"; import { ModelManager } from "../components/ModelManager"; // Mock GraphRAG 拓扑节点 const INITIAL_NODES = [ { id: "node_1", x: 180, y: 50, label: "Beta Tech", type: "tenant", desc: "租户空间组织实体" }, { id: "node_2", x: 80, y: 120, label: "知识库: 退款政策_2026.pdf", type: "document", desc: "主退款规则文档,字数: 3,420" }, { id: "node_3", x: 280, y: 120, label: "知识库: 服务协议_v3.docx", type: "document", desc: "标准渠道协议模板" }, { id: "node_4", x: 80, y: 220, label: "实体: 渠道退费限制", type: "concept", desc: "退款政策第 4 条:限制 30 天内申请" }, { id: "node_5", x: 180, y: 220, label: "实体: 退款折算比率", type: "concept", desc: "公式:按合作月份比例计算退费" }, { id: "node_6", x: 280, y: 220, label: "实体: 30天提前申请", type: "concept", desc: "退款前提:须有书面正式通知" } ]; // Mock GraphRAG 拓扑边关系 const EDGES = [ { from: "node_1", to: "node_2", label: "contains" }, { from: "node_1", to: "node_3", label: "contains" }, { from: "node_2", to: "node_4", label: "rules" }, { from: "node_2", to: "node_5", label: "defines" }, { from: "node_2", to: "node_6", label: "requires" }, { from: "node_4", to: "node_6", label: "aligns" } ]; const NODE_COLORS: Record = { tenant: "#7c3aed", // 紫罗兰 (Violet) document: "#06b6d4", // 青色 (Cyan) concept: "#10b981" // 翠绿 (Emerald) }; export function DatasourcesPage() { const [weights, setWeights] = useState({ vector: 45, fullText: 35, graph: 20 }); const [searchQuery, setSearchQuery] = useState(""); const [selectedNode, setSelectedNode] = useState(null); // 权重调整滑动条 const handleWeightChange = (key: "vector" | "fullText" | "graph", val: number) => { setWeights((prev) => { const next = { ...prev, [key]: val }; // 保持总和为 100% 的动态按比例计算 const diff = 100 - (next.vector + next.fullText + next.graph); const otherKeys = (["vector", "fullText", "graph"] as const).filter((k) => k !== key); // 平摊多余或不足的百分比 let share1 = Math.round(diff / 2); let share2 = diff - share1; next[otherKeys[0]] = Math.max(0, next[otherKeys[0]] + share1); next[otherKeys[1]] = Math.max(0, next[otherKeys[1]] + share2); return next; }); }; // 搜索高亮节点 const filteredNodes = INITIAL_NODES.map((n) => { const matched = searchQuery ? n.label.toLowerCase().includes(searchQuery.toLowerCase()) : false; return { ...n, matched }; }); return (
{/* 1. Embedding 模型配置 (真实组件) */}
{/* 左侧 RAG 融合检索调优面板 */}

RAG 混合检索调参 (RRF 融合权重)

动态配置 mcp-go 的倒排互惠排名融合 (Reciprocal Rank Fusion) 权重,调整回答召回倾向

{/* 向量检索路 */}
向量数据库检索权重 (Milvus) {weights.vector}%
handleWeightChange("vector", Number(e.target.value))} />
{/* 全文检索路 */}
全文倒排索引权重 (Bleve) {weights.fullText}%
handleWeightChange("fullText", Number(e.target.value))} />
{/* 知识图谱检索路 */}
知识图谱三元组检索权重 (Neo4j) {weights.graph}%
handleWeightChange("graph", Number(e.target.value))} />
ℹ️ 调参提示:向量路适合语义匹配;全文路防漏精准术语匹配;图谱路用于提供上下文的长链跨行知识召回(GraphRAG)。三路权重加总为 100%。
{/* 节点详细信息面板 */} {selectedNode && (

{selectedNode.label}

类型: {selectedNode.type}

{selectedNode.desc}

)}
{/* 右侧 GraphRAG 图谱拓扑可视化渲染 */}

GraphRAG 实体知识网络拓扑

展示当前租户空间下文档经 LLM 三元组抽取后导入 Neo4j 形成的实体关联网络

{/* 实体过滤搜索 */} setSearchQuery(e.target.value)} />
{/* 拓扑网络画布 */}
{/* 画边关系 */} {EDGES.map((e, idx) => { const fromNode = INITIAL_NODES.find((n) => n.id === e.from)!; const toNode = INITIAL_NODES.find((n) => n.id === e.to)!; const mx = (fromNode.x + toNode.x) / 2; const my = (fromNode.y + toNode.y) / 2; return ( {e.label} ); })} {/* 画节点 */} {filteredNodes.map((n) => { const color = NODE_COLORS[n.type]; const isSelected = selectedNode?.id === n.id; return ( setSelectedNode(n)} > {/* 高亮光晕 */} {(n.matched || isSelected) && ( )} {/* 节点本体 */} {/* 文字标签 */} {n.label} ); })} {/* 左下角小标识 */}
租户 文档 实体概念
); }