Skip to main content

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()  # or Cache(backend='https://weaviate-instance.com')

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
# ~/.zshrc
export OPENAI_API_KEY=<your-openai-api-key>

You will need to spin up a Weaviate instance in order to use Cadmus. You can do so using Docker in the following:

# db.yml
version: '3.4'
services:
  weaviate:
    image: semitechnologies/weaviate:1.20.2
    restart: always
    command:
      - --host
      - 0.0.0.0
      - --port
      - '8080'
      - --scheme
      - http
    ports:
      - 8080:8080
    volumes:
      - /Users/<USER>/databases/weaviate:/Users/<USER>/databases/weaviate
    environment:
      CLUSTER_HOSTNAME: 'cadmus'
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/Users/<USER>/databases/weaviate'
      DISK_USE_READONLY_PERCENTAGE: 95
      DEFAULT_VECTORIZER_MODULE: 'none'
docker compose -f db.yml up -d

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.

Metadata

Release files for zf-cadmus 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zf-cadmus 0.0.2
File Size Uploaded Provenance Actions
zf-cadmus-0.0.2.tar.gz 8.7 kB Without provenance Details for zf-cadmus-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zf-cadmus 0.0.2
File Interpreter ABI Platform Actions
zf_cadmus-0.0.2-py3-none-any.whl Python 3 none any Details for zf_cadmus-0.0.2-py3-none-any.whl

Total release size: 16.2 kB

Release files / zf-cadmus-0.0.2.tar.gz

Download URL zf-cadmus-0.0.2.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5ec3c26a43d50a1935512e0f40712e3c86e26b69e55dce31d1a70649bdcaf08d
BLAKE2b-256 checksum
How to use checksums
d19444f9a9868ec8be7c8b617c19716d92be74150f73c3b9fd83c3bb09eb70b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / zf_cadmus-0.0.2-py3-none-any.whl

Download URL zf_cadmus-0.0.2-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78e2e8ceb0f0ce76db3724e33c787fc92ed9df88731df0cc073ef48953cf9e2c
BLAKE2b-256 checksum
How to use checksums
3fa71dbd24888fe74fa6216d5a1fd79c3d50a9e113a063cf480bc682a90a8033
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Security for zf-cadmus 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page