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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17abd854e9c11566b8689109d227846376bf3d6e789906b8442a675a5bf4eca9
|
|
| MD5 |
be922976ba59c7e31804670b5427fc35
|
|
| BLAKE2b-256 |
2c87292921f86429b3030c5d39775ea9732a7e89a763c6c726839699f4e6c9d0
|
Provenance
The following attestation bundles were made for recallkit-0.0.2.tar.gz:
Publisher:
publish.yml on elroy-bot/recallkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recallkit-0.0.2.tar.gz -
Subject digest:
17abd854e9c11566b8689109d227846376bf3d6e789906b8442a675a5bf4eca9 - Sigstore transparency entry: 238777287
- Sigstore integration time:
-
Permalink:
elroy-bot/recallkit@243c3184f41797f9123add6ba7b3079a3078be82 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/elroy-bot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@243c3184f41797f9123add6ba7b3079a3078be82 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f12a8bbf954bc7a58facce63a32b62bd002f9bb519e9ca0876690aa772ecb05
|
|
| MD5 |
d96e1cc1db59d307421dd85cd379e5dc
|
|
| BLAKE2b-256 |
a997979b240c4cbea227d900ace6fce16b18fd40fc17904f5333a0d062d22749
|
Provenance
The following attestation bundles were made for recallkit-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on elroy-bot/recallkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recallkit-0.0.2-py3-none-any.whl -
Subject digest:
5f12a8bbf954bc7a58facce63a32b62bd002f9bb519e9ca0876690aa772ecb05 - Sigstore transparency entry: 238777288
- Sigstore integration time:
-
Permalink:
elroy-bot/recallkit@243c3184f41797f9123add6ba7b3079a3078be82 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/elroy-bot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@243c3184f41797f9123add6ba7b3079a3078be82 -
Trigger Event:
release
-
Statement type: