Class BailianClient
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the workspace ID associated with this client.reactor.core.publisher.Mono<com.aliyun.bailian20231229.models.RetrieveResponse>Retrieves relevant documents from a knowledge base with a limit.reactor.core.publisher.Mono<com.aliyun.bailian20231229.models.RetrieveResponse>Retrieves relevant documents from a knowledge base with conversation history.
-
Constructor Details
-
BailianClient
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 inquery- the search query textlimit- 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 inquery- the search query textlimit- 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
Gets the workspace ID associated with this client.- Returns:
- the workspace ID
-