Skip to main content
MongoDb is a class that implements the Db interface using MongoDB as the backend storage system. It provides scalable, document-based storage for agent sessions with support for indexing and efficient querying.
ParameterTypeDefaultDescription
db_clientOptional[MongoClient]-The MongoDB client to use.
db_nameOptional[str]-The name of the database to use.
db_urlOptional[str]-The database URL to connect to.
session_collectionOptional[str]-Name of the collection to store sessions.
memory_collectionOptional[str]-Name of the collection to store memories.
metrics_collectionOptional[str]-Name of the collection to store metrics.
eval_collectionOptional[str]-Name of the collection to store evaluation runs.
knowledge_collectionOptional[str]-Name of the collection to store knowledge documents.

Methods

upsert_sessions

Bulk upsert multiple sessions for improved performance on large datasets. Parameters:
  • sessions (List[Session]): List of sessions to upsert
  • deserialize (Optional[bool]): Whether to deserialize the sessions. Defaults to True
Returns: List[Union[Session, Dict[str, Any]]]

upsert_memories

Bulk upsert multiple memories for improved performance on large datasets. Parameters:
  • memories (List[UserMemory]): List of memories to upsert
  • deserialize (Optional[bool]): Whether to deserialize the memories. Defaults to True
Returns: List[Union[UserMemory, Dict[str, Any]]]
I