Skip to main content

Package that adds a memory layer to AI agents and assistants, enabling persistent context and real-time knowledge management.

Project description



Sinapsis Mem0

Persistent memory for AI agents: store, retrieve, and manage context across conversations and workflows.

🐍 Installation🚀 Features📚 Usage example📙 Documentation🔍 License

The sinapsis-mem0 module adds short and long-term memory to AI agents, enabling dynamic context recall, personalized interactions, and seamless knowledge retention across sessions.

🐍 Installation

Install using your package manager of choice. We encourage the use of uv

Example with uv:

  uv pip install sinapsis-mem0 --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-mem0 --extra-index-url https://pypi.sinapsis.tech

[!IMPORTANT] Templates may require extra dependencies. For development, we recommend installing the package with all the optional dependencies:

with uv:

  uv pip install sinapsis-mem0[all] --extra-index-url https://pypi.sinapsis.tech

or with raw pip:

  pip install sinapsis-mem0[all] --extra-index-url https://pypi.sinapsis.tech

🚀 Features

The templates include the possibility to extend the AI agents with memory persistence using Memory or MemoryClient. Using the client version requires setting the API Key as:

export MEM0_API_KEY="your-api-key-here"

You can check the documentation for the managed client version or for the self hosted open-source version for more details on how to set them up.

Templates Supported

  • Mem0Add: Ingests and structures AI interactions (prompts or responses) into Mem0’s memory format. Supports both discrete facts and full conversation histories.
  • Mem0Delete: Removes memories, either selectively (by ID) or in bulk (e.g., all data for a user/agent).
  • Mem0Get: Retrieves stored memories, from individual entries to entire conversation histories.
  • Mem0Reset: Clears memory storage completely or within a defined scope (user/agent/run).
  • Mem0Search: Dynamically fetches and injects relevant memories into prompts, with configurable formatting.
🌍 General Attributes

These attributes apply to all the available templates:

  • use_managed(bool, required): If True, use the managed Mem0 API (MemoryClient), else the self-hosted infrastructure will be used through the Memory class.
  • memory_config(dict, optional): Parameters to configure either MemoryClient or Memory, depending on the value of use_managed.
➕ Mem0Add Attributes
  • add_kwargs(dict, optional): Dictionary of parameters to pass to MemoryClient or Memory add method. Common keys include user_id or agent_id.
  • generic_key(str, required): Key used to retrieve original prompts from the container's generic data field.
🗑️ Mem0Delete Attributes
  • delete_all(bool, optional): If True, performs a complete memory wipe for the specified scope (agent, run or user). If False, performs targeted deletion based on memory_id. Defaults to False.
  • delete_kwargs(dict, required): Parameters for the deletion operation. Depending on the type of deletion, this may include user_id, agent_id, or memory_id.
📥 Mem0Get Attributes
  • get_all(bool, optional): If True, retrieves all memories for the given context (e.g., user, agent, or run). If False, retrieves a specific memory using parameters like memory_id. Defaults to False.
  • get_kwargs(dict, required): Additional parameters to pass to the memory retrieval method. Can include fields such as user_id, agent_id, or memory_id, depending on the attributes chosen.
🔎 Mem0Search Attributes
  • enclosure(Literal["plain", "bracket", "dashed", "xml"], optional): Determines how relevant memories are injected into the prompt before the user query. Defaults to plain which injects no special section or title, just memories and query.
  • search_kwargs(dict, required): Additional parameters to pass to the memory search method. Can include fields such as user_id, top_k, or threshold, depending on the attributes chosen.

[!TIP] Use CLI command sinapsis info --all-template-names to show a list with all the available Template names installed with Sinapsis Mem0.

[!TIP] Use CLI command sinapsis info --example-template-config TEMPLATE_NAME to produce an example Agent config for the Template specified in TEMPLATE_NAME.

For example, for Mem0Search use sinapsis info --example-template-config Mem0Search to produce the following example config:

agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: Mem0Search
  class_name: Mem0Search
  template_input: InputTemplate
  attributes:
    use_managed: false
    memory_config: '`replace_me:dict[str, typing.Any]`'
    search_kwargs: '`replace_me:dict[str, typing.Any]`'
    enclosure: plain

📚 Usage example

The following agent retrieves all memories for the given user_id and run_id from the Mem0 Platform.

Config
agent:
  name: retriever_agent
  description: Agent that retrieves all memories from Mem0 platform.

templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}

- template_name: Mem0Get
  class_name: Mem0Get
  template_input: InputTemplate
  attributes:
    use_managed: true
    memory_config:
      host: null
      org_id: null
      project_id: null
    get_all: true
    get_kwargs:
      user_id: my_user
      run_id: test

📙 Documentation

Documentation for this and other sinapsis packages is available on the sinapsis website

Tutorials for different projects within sinapsis are available at sinapsis tutorials page

🔍 License

This project is licensed under the AGPLv3 license, which encourages open collaboration and sharing. For more details, please refer to the LICENSE file.

For commercial use, please refer to our official Sinapsis website for information on obtaining a commercial license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sinapsis_mem0-0.1.2.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sinapsis_mem0-0.1.2-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file sinapsis_mem0-0.1.2.tar.gz.

File metadata

  • Download URL: sinapsis_mem0-0.1.2.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.16

File hashes

Hashes for sinapsis_mem0-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2b523eb7826303d1de4c04dde1e49f6a23cb040df0662fae0ee664d37e4eba09
MD5 88356c3ec370a6daf56c0ae18a737046
BLAKE2b-256 967682602dd64a6e99285e8334002f9e63f70fee80c8498e35041eb7052ada93

See more details on using hashes here.

File details

Details for the file sinapsis_mem0-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sinapsis_mem0-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b4934c8557d056b61b4e3f356fcd2cd30eb0927fa7091da940fcc786ea4aa0a5
MD5 858f16aaf55aa238dcb0f857250f9228
BLAKE2b-256 d7428d4cda691634694ebdcb474bf5a04bb01b14796c67f33b9d0e4260dd1b22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page