Class BailianClient

java.lang.Object
io.agentscope.core.rag.integration.bailian.BailianClient

public class BailianClient extends Object
Client for interacting with Alibaba Cloud Bailian Knowledge Base API.

This class wraps the Bailian SDK and provides reactive API methods for knowledge base operations. It handles client initialization, request construction, and error handling.

Example usage:


 BailianConfig config = BailianConfig.builder()
     .accessKeyId(...)
     .accessKeySecret(...)
     .workspaceId(...)
     .build();

 BailianClient client = new BailianClient(config);
 RetrieveResponse response = client.retrieve("indexId", "query").block();
 
  • Constructor Details

    • BailianClient

      public BailianClient(BailianConfig config) throws Exception
      Creates a new BailianClient instance.
      Parameters:
      config - the Bailian configuration
      Throws:
      Exception - if client initialization fails
  • Method Details

    • retrieve

      public reactor.core.publisher.Mono<com.aliyun.bailian20231229.models.RetrieveResponse> retrieve(String indexId, String query, Integer limit)
      Retrieves relevant documents from a knowledge base with a limit.

      This method searches the specified knowledge base (index) for documents relevant to the given query. Results are returned sorted by relevance score, limited to the specified number of documents.

      Parameters:
      indexId - the knowledge base ID to search in
      query - the search query text
      limit - the maximum number of documents to retrieve (null for default)
      Returns:
      a Mono emitting the retrieve response
    • retrieve

      public reactor.core.publisher.Mono<com.aliyun.bailian20231229.models.RetrieveResponse> retrieve(String indexId, String query, Integer limit, List<QueryHistoryEntry> conversationHistory)
      Retrieves relevant documents from a knowledge base with conversation history.

      This method searches the specified knowledge base (index) for documents relevant to the given query. If conversation history is provided and query rewrite is enabled in the configuration, the query will be rewritten based on the conversation context.

      Retrieval parameters (denseSimilarityTopK, sparseSimilarityTopK, reranking, etc.) are read from the BailianConfig provided during client construction.

      Parameters:
      indexId - the knowledge base ID to search in
      query - the search query text
      limit - the maximum number of documents to retrieve (null for default)
      conversationHistory - the conversation history for multi-turn rewrite (can be null)
      Returns:
      a Mono emitting the retrieve response
    • getWorkspaceId

      public String getWorkspaceId()
      Gets the workspace ID associated with this client.
      Returns:
      the workspace ID