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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lore_context_middleware-0.1.0.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

Hashes for lore_context_middleware-0.1.0.tar.gz
Algorithm Hash digest
SHA256 31aeea29cfde0177f24b136a95565268a6071d85e954683b1b23212e5875f4d2
MD5 8f8898bc9ec1129c579aafccf5e10d5d
BLAKE2b-256 e92de44652e58b0acb7211615a1d1cd0b14806de4443c3c425e256529923cbf6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for lore_context_middleware-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8cf99e5898237c970d752d0ce5ab935d0d479a3921f582ce13f3790a89edc971
MD5 4ffb2f2090aae2dd6c201f3cd0dbdbce
BLAKE2b-256 5cd9011345cf29a772f0da9a076da713b381f16b92b975cb2fd5f4dbf7c4fa8a

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