/** * graph-semantic — LLM 增强的图谱语义查询 * v7.0.0+: 让图谱查询从"关键词匹配"升级为"语义理解" * * 核心能力: * 1. 查询词语义扩展 —— "订单相关" → 扩展为 ["order", "booking", "purchase", "交易", "下单", "订单号"] * 2. 候选结果语义排序 —— LLM 理解查询意图后,对匹配结果重新排序 * 3. 零 Token 回退 —— LLM 不可用时,降级到本地规则扩展 */ import type { GraphEntity } from './knowledge-graph'; export interface SemanticExpansion { /** 原始查询词 */ original: string; /** LLM 理解的查询意图 */ intent: string; /** 扩展后的关键词列表(含同义词、相关概念) */ keywords: string[]; /** 业务域推断 */ domain?: string; /** 查询类型推断 */ queryType: 'code' | 'requirement' | 'task' | 'architecture' | 'mixed'; } export interface RankedCandidate { entity: GraphEntity; /** 本地匹配得分 */ localScore: number; /** LLM 语义得分 (0-100) */ semanticScore: number; /** 综合得分 */ finalScore: number; /** LLM 给出的匹配理由 */ reason?: string; } /** * 语义扩展查询词 * 优先使用 LLM,降级到本地规则 */ export declare function expandQuerySemantically(question: string, options?: { useLlm?: boolean; }): Promise; /** * 使用 LLM 对候选结果做语义排序 */ export declare function semanticRank(question: string, candidates: { entity: GraphEntity; localScore: number; }[], options?: { topK?: number; useLlm?: boolean; }): Promise; //# sourceMappingURL=graph-semantic.d.ts.map