SDK middleware for Lore Context — auto-inject memory pre-LLM-call and auto-retain post-LLM-call across OpenAI/Anthropic SDKs.
Project description
lore-context-middleware
Python SDK middleware for Lore Context — wraps openai.OpenAI / anthropic.Anthropic clients to auto-inject memory pre-LLM-call and auto-retain post-LLM-call without requiring the AI to call an MCP tool.
Install
pip install lore-context-middleware lore-context openai
Quick start
import os
from openai import OpenAI
from lore_context import LoreContextApiClient
from lore_context_middleware import with_memory_hooks
lore = LoreContextApiClient(token=os.environ["LORE_API_KEY"])
openai_client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
client = with_memory_hooks(openai_client, lore, mode="hybrid")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "What was that Postgres dump command?"}],
)
Modes
| Mode | inject | retain | tools exposed |
|---|---|---|---|
hybrid (default) |
✅ | ✅ | ✅ |
context |
✅ | ✅ | ❌ |
tools |
❌ | ❌ | ✅ |
See docs/sdk/middleware-modes.md in the lore-cloud repo for full mode semantics.
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 lore_context_middleware-0.1.0rc1.tar.gz.
File metadata
- Download URL: lore_context_middleware-0.1.0rc1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bbc851af852e375234b84ee4f61590046ca9a2709ebf294a2a01a159170b9c6
|
|
| MD5 |
ab46e1ad3028933fb6089b409c2406e2
|
|
| BLAKE2b-256 |
a7c76f9d5bd2f2ea47681b721fdd4c265f1d0fb4e8691ef03b7ef013f910cba1
|
File details
Details for the file lore_context_middleware-0.1.0rc1-py3-none-any.whl.
File metadata
- Download URL: lore_context_middleware-0.1.0rc1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fc1a62258084f2c4909e04c7d9d26e2874219ff2db067bc3bf40538e961b23c
|
|
| MD5 |
0020dc437502bf47f8c0206fd72d8f2a
|
|
| BLAKE2b-256 |
7388f146f9d8a42630d2602940aca4115d18c6fd8d40df42fb3a5f7c6b301ee6
|