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.0rc2.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.0rc2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for lore_context_middleware-0.1.0rc2.tar.gz
Algorithm Hash digest
SHA256 41cd53320d810ed30284c362c1d92a71bbf99c07951ceb0c8f33789ce778f7fa
MD5 6b5e7188e6e88cced1ee3b6ed528aa4f
BLAKE2b-256 8a77d82aaf56ea84fa4035d615c90ab5938e15432e2a646c67410c45e5385e54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lore_context_middleware-0.1.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 353918f61a4ce63e7417c150da505b49100e2d71237c5f3df0240285ba095b25
MD5 a10b973e09668089df89123b67e54887
BLAKE2b-256 947c6bc00f6965a1712d602ee4b56d2dd68c6b8b9fe97423f0ebfd0eba488e0e

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