Package io.agentscope.core.memory.mem0
Class Mem0LongTermMemory.Builder
java.lang.Object
io.agentscope.core.memory.mem0.Mem0LongTermMemory.Builder
- Enclosing class:
- Mem0LongTermMemory
Builder for Mem0LongTermMemory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the agent name identifier.apiBaseUrl(String apiBaseUrl) Sets the Mem0 API base URL.Sets the Mem0 API key.apiType(Mem0ApiType apiType) Sets the Mem0 API type.build()Builds the Mem0LongTermMemory instance.Sets custom metadata to be stored with memories and used for filtering.Sets the run name identifier.Sets the HTTP request timeout.Sets the user id identifier.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
agentName
Sets the agent name identifier.- Parameters:
agentName- The agent's name- Returns:
- This builder
-
userId
Sets the user id identifier.- Parameters:
userId- The user's ID- Returns:
- This builder
-
runName
Sets the run name identifier.- Parameters:
runName- The run/session name or ID- Returns:
- This builder
-
apiBaseUrl
Sets the Mem0 API base URL.- Parameters:
apiBaseUrl- The base URL (e.g., "http://localhost:8000")- Returns:
- This builder
-
apiKey
Sets the Mem0 API key.- Parameters:
apiKey- The API key for authentication (optional for local deployments without authentication)- Returns:
- This builder
-
timeout
Sets the HTTP request timeout.- Parameters:
timeout- The timeout duration- Returns:
- This builder
-
apiType
Sets the Mem0 API type.- Parameters:
apiType- API type enum- Returns:
- This builder
-
metadata
Sets custom metadata to be stored with memories and used for filtering.This metadata will be:
- Included in the request body when recording memories
- Added to the filters when searching/retrieving memories
Example usage:
Map<String, Object> metadata = new HashMap<>(); metadata.put("category", "travel"); metadata.put("priority", "high"); Mem0LongTermMemory memory = Mem0LongTermMemory.builder() .agentName("Assistant") .userId("user_123") .apiBaseUrl("http://localhost:8000") .metadata(metadata) .build();- Parameters:
metadata- Custom metadata map (can be null)- Returns:
- This builder
-
build
Builds the Mem0LongTermMemory instance.- Returns:
- A new Mem0LongTermMemory instance
- Throws:
IllegalArgumentException- If required fields are missing
-