Mem0Client
public class Mem0Client
io/agentscope/core/memory/mem0/Mem0Client.java:44–279Mem 0 客户端,封装与远端服务的连接和调用。位于 io.agentscope.core.memory.mem0 包。核心成员包括 add、search、shutdown、Mem0Client。
HTTP client for interacting with the Mem0 API.
Supports both Platform Mem0 and self-hosted Mem0 deployments:
-
Platform Mem0: Uses endpoints /v1/memories/ and /v2/memories/search/
-
Self-hosted Mem0: Uses endpoints /memories and /memories/search
By default, the client uses Platform Mem0 endpoints. To use self-hosted Mem0, specify "self-hosted" as the apiType parameter.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public Mem0Client(String apiBaseUrl, String apiKey) | 初始化 `Mem0Client` 实例。 Creates a new Mem0Client with specified configuration (defaults to Platform Mem0). |
public Mem0Client(String apiBaseUrl, String apiKey, Duration timeout) | 初始化 `Mem0Client` 实例。 Creates a new Mem0Client with custom timeout (defaults to Platform Mem0). |
public Mem0Client(String apiBaseUrl, String apiKey, Mem0ApiType apiType, Duration timeout) | 初始化 `Mem0Client` 实例。 Creates a new Mem0Client with API type specification. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Mono<Mem0AddResponse> add(Mem0AddRequest request) | 设置添加。 Adds memories to Mem0 by sending messages for processing. |
public Mono<Mem0SearchResponse> search(Mem0SearchRequest request) | 设置搜索。 Searches memories in Mem0 using semantic similarity. |
public void shutdown() | 关闭资源并释放连接。 Shuts down the HTTP client and releases resources. |
构造器详情Constructor Detail
Mem0Client
public Mem0Client(String apiBaseUrl, String apiKey)
初始化 Mem0Client 实例。
Creates a new Mem0Client with specified configuration (defaults to Platform Mem0).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiBaseUrl | String | API 基类 URL(类型 `String`)。The base URL of the Mem0 API (e.g., "http://localhost:8000") |
apiKey | String | API 键(类型 `String`)。The API key for authentication (can be null for local deployments without authentication) |
io/agentscope/core/memory/mem0/Mem0Client.java:71–73Mem0Client
public Mem0Client(String apiBaseUrl, String apiKey, Duration timeout)
初始化 Mem0Client 实例。
Creates a new Mem0Client with custom timeout (defaults to Platform Mem0).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiBaseUrl | String | Mem0 API的基类 URL。The base URL of the Mem0 API |
apiKey | String | API 键(类型 `String`)。The API key for authentication (can be null for local deployments without authentication) |
timeout | Duration | 超时时间(类型 `Duration`)。HTTP request timeout duration |
io/agentscope/core/memory/mem0/Mem0Client.java:83–85Mem0Client
public Mem0Client(String apiBaseUrl, String apiKey, Mem0ApiType apiType, Duration timeout)
初始化 Mem0Client 实例。
Creates a new Mem0Client with API type specification.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
apiBaseUrl | String | Mem0 API的基类 URL。The base URL of the Mem0 API |
apiKey | String | API 键(类型 `String`)。The API key for authentication (can be null for local deployments without authentication) |
apiType | Mem0ApiType | API 类型。API type enum |
timeout | Duration | 超时时间(类型 `Duration`)。HTTP request timeout duration |
io/agentscope/core/memory/mem0/Mem0Client.java:96–120方法详情Method Detail
add
public Mono<Mem0AddResponse> add(Mem0AddRequest request)
设置添加。
Adds memories to Mem0 by sending messages for processing.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | Mem0AddRequest | 请求(类型 `Mem0AddRequest`)。The add request containing messages and metadata |
Mono<Mem0AddResponse>io/agentscope/core/memory/mem0/Mem0Client.java:222–224search
public Mono<Mem0SearchResponse> search(Mem0SearchRequest request)
设置搜索。
Searches memories in Mem0 using semantic similarity.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | Mem0SearchRequest | 请求(类型 `Mem0SearchRequest`)。The search request containing query and filters |
Mono<Mem0SearchResponse>io/agentscope/core/memory/mem0/Mem0Client.java:248–267shutdown
public void shutdown()
关闭资源并释放连接。
Shuts down the HTTP client and releases resources.
io/agentscope/core/memory/mem0/Mem0Client.java:275–278