Skip to main content

Sinapsis templates for LLM memory 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.6.tar.gz (24.0 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.6-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sinapsis_mem0-0.1.6.tar.gz
Algorithm Hash digest
SHA256 1904de5fd46194c614b994fa461dde06a0b50266441946187748721158da8093
MD5 333afa15bc688869f88ce113bbb358cd
BLAKE2b-256 848bb5d0cdda749ee464960086563ab39d1052ff90f499cb96fd2b3f659a6aeb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sinapsis_mem0-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 22ef8db66fed866cdba227067c566e946f7316516ff3f869e96902b11ef3173b
MD5 e7a2a0427c509c4784ff6e37ffdb0aec
BLAKE2b-256 6a6e71bb9ced6e74ee223166df93d01c76b48540829ac69991bb9b34623d84da

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