Class AgentVectorService

java.lang.Object
com.alibaba.cloud.ai.service.AgentVectorService

@Service public class AgentVectorService extends Object
智能体向量存储服务 专门处理智能体相关的向量存储操作,确保数据隔离
  • Constructor Details

    • AgentVectorService

      public AgentVectorService()
  • Method Details

    • initializeSchemaForAgent

      public Boolean initializeSchemaForAgent(Long agentId, com.alibaba.cloud.ai.request.SchemaInitRequest schemaInitRequest)
      为智能体初始化数据库Schema
      Parameters:
      agentId - 智能体ID
      schemaInitRequest - Schema初始化请求
      Returns:
      是否成功
    • addKnowledgeToVector

      public void addKnowledgeToVector(Long agentId, AgentKnowledge knowledge)
      为智能体添加知识文档到向量库
      Parameters:
      agentId - 智能体ID
      knowledge - 知识内容
    • addKnowledgeListToVector

      public void addKnowledgeListToVector(Long agentId, List<AgentKnowledge> knowledgeList)
      为智能体批量添加知识文档到向量库
      Parameters:
      agentId - 智能体ID
      knowledgeList - 知识列表
    • searchKnowledge

      public List<org.springframework.ai.document.Document> searchKnowledge(Long agentId, String query, int topK)
      从向量库中搜索相关知识
      Parameters:
      agentId - 智能体ID
      query - 查询文本
      topK - 返回结果数量
      Returns:
      相关文档列表
    • searchKnowledgeByType

      public List<org.springframework.ai.document.Document> searchKnowledgeByType(Long agentId, String query, int topK, String knowledgeType)
      从向量库中搜索特定类型的知识
      Parameters:
      agentId - 智能体ID
      query - 查询文本
      topK - 返回结果数量
      knowledgeType - 知识类型
      Returns:
      相关文档列表
    • deleteKnowledgeFromVector

      public void deleteKnowledgeFromVector(Long agentId, Integer knowledgeId)
      删除智能体的特定知识文档
      Parameters:
      agentId - 智能体ID
      knowledgeId - 知识ID
    • deleteAllVectorDataForAgent

      public void deleteAllVectorDataForAgent(Long agentId)
      删除智能体的所有向量数据
      Parameters:
      agentId - 智能体ID
    • getVectorStatistics

      public Map<String,Object> getVectorStatistics(Long agentId)
      获取智能体向量存储统计信息
      Parameters:
      agentId - 智能体ID
      Returns:
      统计信息
    • getAgentDatasources

      public List<Map<String,Object>> getAgentDatasources(Long agentId)
      获取智能体配置的数据源列表 从数据库中查询智能体关联的数据源信息
    • getDatasourceTables

      public List<String> getDatasourceTables(Integer datasourceId)
      获取数据源的表列表
      Parameters:
      datasourceId - 数据源ID
      Returns:
      表名列表
    • initializeSchemaForAgentWithDatasource

      public Boolean initializeSchemaForAgentWithDatasource(Long agentId, Integer datasourceId, List<String> tables)
      使用数据源ID为智能体初始化数据库Schema
      Parameters:
      agentId - 智能体ID
      datasourceId - 数据源ID
      tables - 表列表
      Returns:
      是否成功
    • chatWithAgent

      public String chatWithAgent(Long agentId, String query)
      智能体聊天功能
      Parameters:
      agentId - 智能体ID
      query - 用户查询
      Returns:
      智能体回答