Class AgentVectorStoreManager

java.lang.Object
com.alibaba.cloud.ai.service.simple.AgentVectorStoreManager

@Component public class AgentVectorStoreManager extends Object
智能体向量存储管理器 为每个智能体提供独立的向量存储实例,确保数据隔离
  • Constructor Details

    • AgentVectorStoreManager

      public AgentVectorStoreManager(org.springframework.ai.embedding.EmbeddingModel embeddingModel)
  • Method Details

    • getOrCreateVectorStore

      public org.springframework.ai.vectorstore.SimpleVectorStore getOrCreateVectorStore(String agentId)
      获取或创建智能体专用的向量存储
      Parameters:
      agentId - 智能体ID
      Returns:
      智能体专用的SimpleVectorStore实例
    • addDocuments

      public void addDocuments(String agentId, List<org.springframework.ai.document.Document> documents)
      为指定智能体添加文档
      Parameters:
      agentId - 智能体ID
      documents - 要添加的文档列表
    • similaritySearch

      public List<org.springframework.ai.document.Document> similaritySearch(String agentId, String query, int topK)
      为指定智能体搜索相似文档
      Parameters:
      agentId - 智能体ID
      query - 查询文本
      topK - 返回结果数量
      Returns:
      相似文档列表
    • similaritySearchWithFilter

      public List<org.springframework.ai.document.Document> similaritySearchWithFilter(String agentId, String query, int topK, String vectorType)
      为指定智能体搜索相似文档(带过滤条件)
      Parameters:
      agentId - 智能体ID
      query - 查询文本
      topK - 返回结果数量
      vectorType - 向量类型过滤
      Returns:
      相似文档列表
    • deleteAgentData

      public void deleteAgentData(String agentId)
      删除指定智能体的所有数据
      Parameters:
      agentId - 智能体ID
    • deleteDocuments

      public void deleteDocuments(String agentId, List<String> documentIds)
      删除指定智能体的特定文档
      Parameters:
      agentId - 智能体ID
      documentIds - 要删除的文档ID列表
    • deleteDocumentsByType

      public void deleteDocumentsByType(String agentId, String vectorType)
      删除指定智能体的特定类型文档
      Parameters:
      agentId - 智能体ID
      vectorType - 向量类型
    • hasAgentData

      public boolean hasAgentData(String agentId)
      检查智能体是否有向量数据
      Parameters:
      agentId - 智能体ID
      Returns:
      是否有数据
    • getDocumentCount

      public int getDocumentCount(String agentId)
      获取智能体的文档数量(估算)
      Parameters:
      agentId - 智能体ID
      Returns:
      文档数量
    • getAllAgentIds

      public Set<String> getAllAgentIds()
      获取所有有数据的智能体ID
      Returns:
      智能体ID集合
    • getStatistics

      public Map<String,Object> getStatistics()
      获取向量存储统计信息
      Returns:
      统计信息