feat: 支持一库一工具 Agentic RAG
- 将知识库声明与 Retriever 绑定为独立 Registration 并注册到 AgentScope Toolkit - 统一检索分数、最终文档事件与长答案引用语义 - 补齐历史会话、工具类加载器和知识库调用状态回归测试
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
package com.easyagents.agent.runtime;
|
||||
|
||||
import com.easyagents.agent.runtime.knowledge.AgentKnowledgeRetriever;
|
||||
import com.easyagents.agent.runtime.knowledge.AgentKnowledgeRegistration;
|
||||
import com.easyagents.agent.runtime.media.AgentMediaResolver;
|
||||
import com.easyagents.agent.runtime.memory.AgentMemorySnapshot;
|
||||
import com.easyagents.agent.runtime.persistence.conversation.AgentConversationRecorder;
|
||||
import com.easyagents.agent.runtime.persistence.conversation.noop.NoopAgentConversationRecorder;
|
||||
import com.easyagents.agent.runtime.persistence.session.AgentSessionStore;
|
||||
import com.easyagents.agent.runtime.persistence.session.noop.NoopAgentSessionStore;
|
||||
import com.easyagents.agent.runtime.tool.AgentToolInvoker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -44,7 +47,12 @@ public class AgentInitRequest {
|
||||
/**
|
||||
* 知识库集合,实现AgentKnowledgeRetriever接口以进行知识检索动作。
|
||||
*/
|
||||
private Map<String, AgentKnowledgeRetriever> knowledgeRetrievers = new LinkedHashMap<>();
|
||||
private List<AgentKnowledgeRegistration> knowledgeRegistrations = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 首次构建 Agent 时装载的对话历史快照。
|
||||
*/
|
||||
private AgentMemorySnapshot memorySnapshot = new AgentMemorySnapshot();
|
||||
|
||||
/**
|
||||
* 对话事件记录器,用于记录运行时事件流。
|
||||
@@ -156,17 +164,37 @@ public class AgentInitRequest {
|
||||
*
|
||||
* @return 知识库检索器
|
||||
*/
|
||||
public Map<String, AgentKnowledgeRetriever> getKnowledgeRetrievers() {
|
||||
return knowledgeRetrievers;
|
||||
public List<AgentKnowledgeRegistration> getKnowledgeRegistrations() {
|
||||
return knowledgeRegistrations;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置知识库检索器。
|
||||
*
|
||||
* @param knowledgeRetrievers 知识库检索器
|
||||
* @param knowledgeRegistrations 知识库运行时绑定
|
||||
*/
|
||||
public void setKnowledgeRetrievers(Map<String, AgentKnowledgeRetriever> knowledgeRetrievers) {
|
||||
this.knowledgeRetrievers = knowledgeRetrievers == null ? new LinkedHashMap<>() : knowledgeRetrievers;
|
||||
public void setKnowledgeRegistrations(List<AgentKnowledgeRegistration> knowledgeRegistrations) {
|
||||
this.knowledgeRegistrations = knowledgeRegistrations == null
|
||||
? new ArrayList<>()
|
||||
: new ArrayList<>(knowledgeRegistrations);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首次构建 Agent 时的对话历史快照。
|
||||
*
|
||||
* @return 对话历史快照
|
||||
*/
|
||||
public AgentMemorySnapshot getMemorySnapshot() {
|
||||
return memorySnapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置首次构建 Agent 时的对话历史快照。
|
||||
*
|
||||
* @param memorySnapshot 对话历史快照
|
||||
*/
|
||||
public void setMemorySnapshot(AgentMemorySnapshot memorySnapshot) {
|
||||
this.memorySnapshot = memorySnapshot == null ? new AgentMemorySnapshot() : memorySnapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user