Class BailianMemoryClient
java.lang.Object
io.agentscope.core.memory.bailian.BailianMemoryClient
HTTP client for interacting with Bailian Long Term Memory API.
This client provides reactive API methods for memory operations including adding memories and searching for relevant memories using semantic similarity.
Example usage:
// Using builder
BailianMemoryClient client = BailianMemoryClient.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.build();
// Add memory
BailianAddRequest addRequest = BailianAddRequest.builder()
.userId("user_001")
.memoryLibraryId("memory_library_123")
.projectId(project_id_123);
.profileSchema(profile_schema_123);
.messages(messages)
.build();
client.add(addRequest).block();
// Search memory
BailianSearchRequest searchRequest = BailianSearchRequest.builder()
.userId("user_001")
.messages(searchMessages)
.memoryLibraryId("memory_library_123")
.projectIds(List.of("project_id_123"));
.topK(5)
.build();
BailianSearchResponse response = client.search(searchRequest).block();
// Close the client when done
client.close();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<BailianAddResponse>add(BailianAddRequest request) Adds memories to Bailian Long Term Memory.static BailianMemoryClient.Builderbuilder()Creates a new builder forBailianMemoryClient.voidclose()Closes the HTTP transport and releases resources.reactor.core.publisher.Mono<BailianSearchResponse>search(BailianSearchRequest request) Searches for relevant memories based on semantic similarity.
-
Method Details
-
add
Adds memories to Bailian Long Term Memory.This method calls the POST /api/v2/apps/memory/add endpoint to store conversation messages as memory nodes. Bailian will automatically extract key information from the messages.
- Parameters:
request- the add memory request containing messages and metadata- Returns:
- a Mono emitting the add memory response
-
search
Searches for relevant memories based on semantic similarity.This method calls the POST /api/v2/apps/memory/memory_nodes/search endpoint to find memories relevant to the provided query messages. Results are ordered by relevance score.
- Parameters:
request- the search memory request containing query and filters- Returns:
- a Mono emitting the search memory response
-
close
public void close()Closes the HTTP transport and releases resources. -
builder
Creates a new builder forBailianMemoryClient.- Returns:
- a new Builder instance
-