Skip to main content

Lightweight memory integration for LLMs

Project description

RecallKit

RecallKit is a lightweight memory integration toolkit for Large Language Models (LLMs). It provides utilities to manage and optimize the context window of LLM conversations.

Current Features

Message Compression

The core functionality currently implemented is context compression for LLM conversations. When working with LLMs, the context window (the amount of text the model can consider at once) is limited. As conversations grow longer, they may exceed this limit, requiring some messages to be dropped or summarized.

RecallKit's ContextCompressor intelligently manages this process by:

  • Preserving system messages (instructions to the LLM)
  • Prioritizing recent messages over older ones
  • Respecting token limits for different models
  • Optionally filtering out messages older than a specified age
  • Maintaining the relationship between tool calls and their corresponding messages

Example Usage

from recallkit.compression import ContextCompressor
from datetime import timedelta

# Create a compressor for a specific model with a token target
compressor = ContextCompressor.for_model(
    model_name="gpt-4o-mini",
    context_refresh_target_tokens=4000,
    max_in_context_message_age=timedelta(hours=1)  # Optional
)

# Compress a list of messages
kept_messages, dropped_messages = compressor.compress(conversation_messages)

# Use kept_messages in your next LLM call

The compressor works with both object-style messages (with attributes) and dictionary-style messages (compatible with most LLM APIs).

Future Extensions

RecallKit is designed to be extended with additional memory management features for LLMs. Future versions may include:

  • Conversation summarization
  • Long-term memory storage and retrieval
  • Semantic search across conversation history
  • Integration with vector databases
  • Customizable compression strategies

Installation

pip install recallkit

Requirements

  • Python 3.10+
  • litellm (for token counting)

License

MIT

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

recallkit-0.0.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

recallkit-0.0.2-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file recallkit-0.0.2.tar.gz.

File metadata

  • Download URL: recallkit-0.0.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for recallkit-0.0.2.tar.gz
Algorithm Hash digest
SHA256 17abd854e9c11566b8689109d227846376bf3d6e789906b8442a675a5bf4eca9
MD5 be922976ba59c7e31804670b5427fc35
BLAKE2b-256 2c87292921f86429b3030c5d39775ea9732a7e89a763c6c726839699f4e6c9d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for recallkit-0.0.2.tar.gz:

Publisher: publish.yml on elroy-bot/recallkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file recallkit-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: recallkit-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for recallkit-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f12a8bbf954bc7a58facce63a32b62bd002f9bb519e9ca0876690aa772ecb05
MD5 d96e1cc1db59d307421dd85cd379e5dc
BLAKE2b-256 a997979b240c4cbea227d900ace6fce16b18fd40fc17904f5333a0d062d22749

See more details on using hashes here.

Provenance

The following attestation bundles were made for recallkit-0.0.2-py3-none-any.whl:

Publisher: publish.yml on elroy-bot/recallkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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