Skip to main content

Complete cognitive middleware stack for LLMs. Memory + routing + cache + observability in one install.

Project description

kore-stack

Complete cognitive middleware stack for LLMs. One install, everything connected.

Memory + Identity + Cache + Routing + Observability + A/B Testing.

The difference with LangChain/LlamaIndex: kore's routing is based on formal proof complexity theory (Selector Complexity), not heuristics.

Install

pip install kore-stack               # core (Ollama-ready)
pip install kore-stack[openai]       # + OpenAI
pip install kore-stack[anthropic]    # + Anthropic
pip install kore-stack[all]          # everything

Quick start

from kore_stack import Mind, Bridge, OllamaProvider

mind = Mind("agent.db")
llm = OllamaProvider(model="llama3.2")
bridge = Bridge(mind=mind, llm=llm, cache_ttl=3600.0)

response = bridge.think("Help me with my proof", user="carlos")

What's new in v0.1.1

  • kore-mind>=0.3.1: optimized Ollama embeddings — connection reuse, LRU cache, batch embedding (embed.batch(texts)), fallback warnings
  • kore-bridge>=0.3.1: dependency bump

What's in the stack

kore-mind — Persistent memory engine

from kore_stack import Mind

mind = Mind("agent.db", enable_traces=True)
mind.experience("User likes Python", source="carlos")
memories = mind.recall("Python", source="carlos")

# Scoped views per user
alice = mind.scoped("alice")
alice.experience("Prefers Rust")

kore-bridge — LLM cognitive middleware

from kore_stack import Bridge, OllamaProvider

bridge = Bridge(
    mind=mind,
    llm=OllamaProvider(),
    cache_ttl=3600.0,    # smart cache
    rate_limit=3,         # cognitive rate limiting
    rate_window=3600.0,
)

# Cache hit → no LLM call. Rate limited → respond from memory.
response = bridge.think("What is P vs NP?", user="carlos")

sc-router — Routing based on Selector Complexity

from kore_stack import (
    SCRouterProvider, ToolCatalog, Tool,
    OllamaProvider, Bridge, Mind,
)
from kore_bridge.providers import OpenAIProvider

# Define your tool catalog
catalog = ToolCatalog()
catalog.register(Tool(
    name="calculator",
    description="Arithmetic calculations",
    input_types={"expression"},
    output_types={"number"},
    capability_tags={"math", "calculate"},
))

# SC routing: simple queries → local Ollama, complex → GPT-4
router = SCRouterProvider(
    providers={
        "fast": OllamaProvider(model="llama3.2"),
        "quality": OpenAIProvider(model="gpt-4o"),
    },
    catalog=catalog,
)

bridge = Bridge(mind=Mind("agent.db"), llm=router)
bridge.think("What is 2+2?")        # SC(0) → Ollama
bridge.think("Analyze market trends, cross-reference sentiment, build prediction model")
                                      # SC(2-3) → GPT-4
print(router.last_sc_level)          # 0, 1, 2, or 3

A/B Testing

from kore_stack import Experiment, OllamaProvider, Mind

exp = Experiment(
    Mind("test.db"),
    variant_a=OllamaProvider(model="llama3.2"),
    variant_b=OllamaProvider(model="mistral"),
)

result = exp.run("Explain recursion")
print(f"A: {result.time_a_ms:.0f}ms, B: {result.time_b_ms:.0f}ms, faster: {result.faster}")

Architecture

┌─────────────┐
│   Your App  │
└──────┬──────┘
       │
┌──────▼──────┐
│ kore-bridge │  Cache → Rate Limit → SC Route → LLM
│  (Bridge)   │
└──────┬──────┘
       │
┌──────▼──────┐     ┌───────────┐
│  kore-mind  │     │ sc-router │
│   (Mind)    │     │  SC(0-3)  │
│   SQLite    │     └───────────┘
└─────────────┘

Packages

Package PyPI What it does
kore-mind pip install kore-mind Memory, identity, traces, cache storage
kore-bridge pip install kore-bridge LLM integration, cache logic, rate limiting, A/B
sc-router pip install sc-router Query routing by Selector Complexity
kore-stack pip install kore-stack All of the above, one install

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

kore_stack-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

kore_stack-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file kore_stack-0.1.1.tar.gz.

File metadata

  • Download URL: kore_stack-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kore_stack-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fad27251b72310891c78c88770290365d79fae048a355c95c2edf296afd933a5
MD5 2e3e61acaa6798380aa3aa3d8b36222c
BLAKE2b-256 24f65db82c9b2827a7eeccaf3e5bb28dcc13367d49f68e63deb36f0dcaf6991c

See more details on using hashes here.

File details

Details for the file kore_stack-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kore_stack-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kore_stack-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52045bfad084451cef023e3818978a2f2cbe6741a987ca1af9947dd3964258c1
MD5 a480c2f3ea0cae16bef8303a4ac289d9
BLAKE2b-256 0c79b632acf04e84cb814359a714520fa04280e8afa75192c87add9a6564e654

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