Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lore_context_middleware-0.1.0rc1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

lore_context_middleware-0.1.0rc1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file lore_context_middleware-0.1.0rc1.tar.gz.

File metadata

File hashes

Hashes for lore_context_middleware-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 3bbc851af852e375234b84ee4f61590046ca9a2709ebf294a2a01a159170b9c6
MD5 ab46e1ad3028933fb6089b409c2406e2
BLAKE2b-256 a7c76f9d5bd2f2ea47681b721fdd4c265f1d0fb4e8691ef03b7ef013f910cba1

See more details on using hashes here.

File details

Details for the file lore_context_middleware-0.1.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for lore_context_middleware-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 1fc1a62258084f2c4909e04c7d9d26e2874219ff2db067bc3bf40538e961b23c
MD5 0020dc437502bf47f8c0206fd72d8f2a
BLAKE2b-256 7388f146f9d8a42630d2602940aca4115d18c6fd8d40df42fb3a5f7c6b301ee6

See more details on using hashes here.

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