Overview
TheUser class represents a user in your RecallrAI project. It provides methods for managing sessions, memories, messages, and merge conflicts.
Properties
Unique identifier for the user.
User metadata as a dictionary.
UTC timestamp when the user was created.
UTC timestamp of the user’s last activity.
User Management Methods
update()
Update the user’s metadata or ID.New metadata to replace the existing metadata. Completely replaces the old metadata.
Optional new user ID. Must be unique within your project.
UserNotFoundError, UserAlreadyExistsError
refresh()
Refresh the user instance with the latest data from the server.UserNotFoundError
delete()
Delete the user and all associated data.UserNotFoundError
Session Management Methods
create_session()
Create a new session for the user.Automatically process the session after this many seconds of inactivity. Optional.
Optional metadata to associate with the session.
Optional custom timestamp for when the session was created. Must be a timezone-aware datetime in UTC. Useful for benchmarking or importing historical data.
Session object
Raises: UserNotFoundError, ValueError (if timestamp is not UTC)
Example with Custom Timestamp
get_session()
Retrieve an existing session by ID.The UUID of the session to retrieve.
Session object
Raises: UserNotFoundError, SessionNotFoundError
list_sessions()
List all sessions for the user with optional filtering.Number of sessions to skip. Default:
0Maximum number of sessions to return. Default:
10Filter sessions by metadata fields.
Filter by session status. Available statuses:
PENDING, PROCESSING, PROCESSED, FAILEDSessionList object with sessions, total, and has_more fields
Memory Management Methods
list_memories()
List user memories with optional filtering.Filter by memory categories. Only memories matching these categories are returned.
Filter by specific session IDs.
Filter by session metadata.
Number of memories to skip. Default:
0Maximum number of memories to return. Range: 1-200. Default:
20Include version history for each memory. Default:
TrueInclude related memories. Default:
TrueMemoryList object
Raises: UserNotFoundError, InvalidCategoriesError
Memory Item Fields
Each memory item contains:memory_id: Unique identifier for the current versioncategories: List of category stringscontent: Current version’s content textevent_date_start: UTC timestamp when the event started (actual event time, not when it was recorded)event_date_end: UTC timestamp when the event ended (actual event time, not when it was recorded)created_at: UTC timestamp when this memory version was created (when it was recorded in the system)session_id: ID of the session that created this versionversion_number: Current version numbertotal_versions: Total number of versionshas_previous_versions: Boolean indicating multiple versions existprevious_versions: List ofMemoryVersionInfoobjects (optional)connected_memories: List ofMemoryRelationshipobjects (optional)merge_conflict_in_progress: Boolean indicating active conflict
The difference between
event_date_start/event_date_end and created_at:- Event dates represent when the event actually occurred in the real world (e.g., “I met John on Monday”)
- Created at represents when the memory was extracted and stored in the system
Message Methods
get_last_n_messages()
Retrieve the most recent messages for the user across all sessions.Number of recent messages to retrieve.
MessageList object with messages field
Raises: UserNotFoundError
Merge Conflict Methods
list_merge_conflicts()
List merge conflicts for the user.Number of conflicts to skip. Default:
0Maximum number of conflicts to return. Default:
10Filter by status:
PENDING, IN_QUEUE, RESOLVING, RESOLVED, FAILEDSort field:
created_at or resolved_at. Default: created_atSort order:
asc or desc. Default: descMergeConflictList object
get_merge_conflict()
Get a specific merge conflict by ID.The UUID of the merge conflict to retrieve.
MergeConflict object
Raises: UserNotFoundError, MergeConflictNotFoundError
Async User
For async applications, useAsyncUser:
Working with Historical Data
When importing historical data or running benchmarks, you can preserve original timestamps:When sessions are processed with custom timestamps, the memory extraction and context retrieval use that timestamp instead of the current time. This ensures accurate temporal context for benchmarking and historical data analysis.