Skip to main content

pd supercharges your development workflows

Project description

Cadmus

Cadmus provides a unified memory abstraction for AI Agents. It has a pluggable memory module which makes retrieving the latest and most similar information super easy.

Motivation

Current AI agents and their memory mechanism do not provide a unified way to store and retrieve the latest and most similar messages which is often time needed when using the APIs of LLMS providers e.g. OpenAI.

In a real-world AI product, it is generally not feasible to store all this information in the LLM context. For example, in a chatbot, the conversation history can be range from months to years. Similarly, the functions that the chatbot can perform will be in the hundreds or thousands.

Cadmus provides a pluggable memory module that can be easily used by other AI products. It provides a Cache abstraction which at the backend connects to an Embedding store. The Cache can be used to store different types of information e.g. Messages, Notes and Functions.

  1. Messages represent the ongoing conversation history between the user and the AI.

  2. Notes represent the notes taken down by the AI which can range from summaries to action items.

  3. Functions represent the functions that the AI can perform when asked by the user.

By utilizing these unified abstractions provided by Cadmus, you can offload the storage and retrieval parts of your AI products.

Usage

Cadmus makes it super easy to retrieve the latest and most similar information in order to be passed to the LLM APIs.

from cadmus import Cache

cache = Cache()

cache.add_message(...)

# Get a combination of top and similar messages
messages = cache.get_messages()

# Get the latest 10 messages
messages1 = cache.get_messages(latest=10, similar=0)

# Get top 10 messages similar to the latest message
messages2 = cache.get_messages(latest=1, similar=10) 

In the above example, calling the .get_messages() method will return the top and similar messages from the cache. The top messages are the ones that are the most recent messages and the similar messages are the ones that are similar to the top messages.

Installation

pip install zf-cadmus

Appendix

Cadmus is inspired by the following papers:

MemGPT

MemGPT takes a step towards long-memory AI agents by by introducing Main Context and External Context.

Main Context contains the Conversation History and Working Context.

External Context Contains the Recall Storage and Archival Storage.

Recall Storage (implemented as an Embedding Database) is used to offload the extra conversation history that does not fit into the LLM Context, while Archival Storage is used to offload the extra working context that does not fit into the LLM Context.

  1. Conversation History -> Recall Storage
  2. Working Context -> Archival Storage

However, MemGPT did not provide any useful abstractions that can be easily extended to or used by other AI products.

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

zf-cadmus-0.0.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

zf_cadmus-0.0.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file zf-cadmus-0.0.1.tar.gz.

File metadata

  • Download URL: zf-cadmus-0.0.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for zf-cadmus-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b121e638c8e1aed4cfc3da9c90005a960bfca4d24095d572072eb65a73ce0352
MD5 d0d86646daa2504551f4f34237af2a78
BLAKE2b-256 38e2b757c0c9047e6c0cb6739c98664be6e4f0019ea90292ad25880c869ef163

See more details on using hashes here.

File details

Details for the file zf_cadmus-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: zf_cadmus-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for zf_cadmus-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8ce3317c4be4f87b4b14a8f3264c70e28802cab8c771ff64b56f241e0290d015
MD5 a65d20d34a650243dd4489a212c76aba
BLAKE2b-256 755247f9e1212c2ac2a0c7c9a9970825cb9ea5bae6d526b0cec6259fcf2be375

See more details on using hashes here.

Supported by

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