diff --git a/packages/services/conversation-service/src/infrastructure/agents/coordinator/context-injector.service.ts b/packages/services/conversation-service/src/infrastructure/agents/coordinator/context-injector.service.ts index 94f18f9..809ac97 100644 --- a/packages/services/conversation-service/src/infrastructure/agents/coordinator/context-injector.service.ts +++ b/packages/services/conversation-service/src/infrastructure/agents/coordinator/context-injector.service.ts @@ -17,7 +17,6 @@ import { Injectable, Logger } from '@nestjs/common'; import Anthropic from '@anthropic-ai/sdk'; import { ContextType, - ContextData, ContextInjectionBlock, ContextInjectionResult, ContextInjectorConfig, @@ -27,13 +26,7 @@ import { DEFAULT_CONTEXT_CONFIG, } from '../types/context.types'; import { ClaudeMessage } from '../types/agent.types'; - -/** Dependency: knowledge service client */ -export interface IKnowledgeClient { - retrieveForPrompt(query: string, userId: string, category?: string): Promise; - getUserMemories(userId: string, limit?: number): Promise>; - getRelevantExperiences(query: string, limit?: number): Promise>; -} +import { KnowledgeClientService } from '../../knowledge/knowledge-client.service'; @Injectable() export class ContextInjectorService { @@ -42,7 +35,7 @@ export class ContextInjectorService { private config: ContextInjectorConfig = DEFAULT_CONTEXT_CONFIG; constructor( - private readonly knowledgeClient: IKnowledgeClient, + private readonly knowledgeClient: KnowledgeClientService, ) {} /** @@ -220,14 +213,14 @@ export class ContextInjectorService { } try { - const memories = await this.knowledgeClient.getUserMemories(ctx.userId, 10); + const memories = await this.knowledgeClient.getUserTopMemories(ctx.userId, 10); if (!memories || memories.length === 0) return null; const content = [ ``, `用户历史记忆 (${memories.length} 条):`, ...memories.map(m => - ` - [${m.type}] ${m.content} (重要度: ${m.importance})` + ` - [${m.memoryType}] ${m.content} (重要度: ${m.importance})` ), ``, ].join('\n'); @@ -294,9 +287,9 @@ export class ContextInjectorService { } try { - const knowledge = await this.knowledgeClient.retrieveForPrompt( - query, ctx.userId, - ); + const knowledge = await this.knowledgeClient.retrieveForPrompt({ + query, userId: ctx.userId, + }); if (!knowledge) return null; const content = [ @@ -335,14 +328,14 @@ export class ContextInjectorService { if (!query) return null; try { - const experiences = await this.knowledgeClient.getRelevantExperiences(query, 3); + const experiences = await this.knowledgeClient.searchExperiences({ query, limit: 3 }); if (!experiences || experiences.length === 0) return null; const content = [ ``, `相关系统经验:`, ...experiences.map(e => - ` - [${e.type}] ${e.content} (置信度: ${e.confidence}%)` + ` - [${e.experienceType}] ${e.content} (置信度: ${e.confidence}%)` ), ``, ].join('\n');