Skip to main content

Give AI a pattern to follow

Agents, LLMs, RAG, Skills — wired together, no glue code.

PyPI version Python versions License

Lexigram AI demo

lexigram-ai is the AI layer of the lexigram framework: a thin coordinator that wires the lexigram-ai family — agents, LLMs, RAG, memory, skills, MCP, session, workers, observability, feedback, guard, governance, evaluation, prompt, relay — into the container through entry-point discovery. one install, one Application.boot, and the whole family is resolvable by contract. every backend is swappable: run it on your own infra or point it at an API.

  • wired, not glued. agents, llms, rag, memory — one container, one boot call.
  • async, end to end. the container, the modules, the controllers — concurrency-safe by construction.
  • contracts everywhere. every package talks through protocols, so swapping an implementation never ripples.
  • local-first. defaults point at any OpenAI-compatible server — Ollama, LM Studio, vLLM — hosted providers are a config change away.

→ full docs at docs.lexigram.dev

install

uv add "lexigram[ai,web]"    # framework + web + ai + server (what the example below uses)
uv add lexigram-ai           # just the coordinator
pip install "lexigram[ai,web]"

60 seconds, end to end

from lexigram import Application
from lexigram.web import Controller, get, WebModule
from lexigram.web.server import run_server
from lexigram.ai.llm import LLMModule, ClientConfig
from lexigram.contracts.ai import LLMClientProtocol, ChatMessage, Role


class ChatController(Controller):
    def __init__(self, llm: LLMClientProtocol):
        self.llm = llm

    @get("/chat")
    async def chat(self, q: str) -> dict:
        messages = [ChatMessage(role=Role.USER, content=q)]
        result = await self.llm.complete(messages)
        return {"reply": result.unwrap().content}


app = Application()
app.add_modules(
    [
        # Local-first. To talk to a hosted provider instead, set
        # `provider="openai"` (or "anthropic", "groq", ...) and supply
        # the matching API key.
        LLMModule.configure(
            ClientConfig(
                provider="ollama",
                model="llama3.2",
                api_base="http://localhost:11434",
                api_key="ollama",
            )
        ),
        WebModule.configure(controllers=[ChatController]),
    ]
)

run_server(app, port=8000)

→ http://localhost:8000/chat?q=hello

No API key needed if you're pointing at a local model. To talk to a hosted provider instead, set provider="openai" (or "anthropic", "groq", …), drop api_base, and supply the matching API key — or let LLMModule.configure() read the whole block from LEX_AI_LLM__* env vars.

what just happened?

  • Application.boot assembled two modules — an LLM client and a web server — into one container and started them together.
  • LLMModule.configure(...) declared a provider, a model, and an endpoint. No SDK, no per-provider code.
  • ChatController resolved LLMClientProtocol by type from the container. Swap the provider; the controller never changes.
lexigram-ai
├── umbrella        entry point · discovers subsystems
├── llm             provider-agnostic clients
├── agents          tools, react, and beyond
├── rag             chunkers, embedders, retrieval pipelines
├── memory          working, episodic, semantic stores
├── skills          versioned agent capabilities
├── session         conversation state and resumption
├── mcp             model-context-protocol clients
├── workers         background AI jobs
├── observability   tracing and metrics
├── feedback        quality loops
├── guard           input/output safety gates
├── governance      policy, audit, budgets
├── evaluation      evals and quality gates
├── prompt          versioned prompt templates
├── relay           protocol conversion engine
└── relay-gateway   HTTP gateway for relay

what's in the box

the whole family lives in this repository under experimental/ai/ — experimental tier, API stability is not guaranteed between releases. same container, same contracts, same rules as the stable core.

  • lexigram-ai — the coordinator (this package)
  • lexigram-ai-llm — provider-agnostic clients for Ollama, OpenAI, Anthropic, Groq, Mistral, and more
  • lexigram-ai-agents — tools, react, and beyond
  • lexigram-ai-rag — chunkers, embedders, retrieval pipelines
  • lexigram-ai-memory — working, episodic, semantic stores
  • lexigram-ai-skills — versioned agent capabilities
  • lexigram-ai-session — conversation state and resumption
  • lexigram-ai-mcp — model-context-protocol clients
  • lexigram-ai-workers — background AI jobs
  • lexigram-ai-observability — tracing and metrics
  • lexigram-ai-feedback — quality loops
  • lexigram-ai-guard — input/output safety gates
  • lexigram-ai-governance — policy, audit, budgets
  • lexigram-ai-evaluation — evals and quality gates
  • lexigram-ai-prompt — versioned prompt templates
  • lexigram-ai-relay — protocol conversion engine
  • lexigram-ai-relay-gateway — HTTP gateway for relay

early on purpose

The AI layer is in 0.1 — which means you can still change it. APIs may shift before 1.0, so pin your versions, and tell us what feels wrong. Shaping a framework is more fun when it's still soft.

pointers

Download files

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

Source Distribution

lexigram_ai-0.1.5001.tar.gz (6.2 MB view details)

Uploaded Source

Built Distribution

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

lexigram_ai-0.1.5001-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_ai-0.1.5001.tar.gz.

File metadata

  • Download URL: lexigram_ai-0.1.5001.tar.gz
  • Upload date:
  • Size: 6.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for lexigram_ai-0.1.5001.tar.gz
Algorithm Hash digest
SHA256 9a6fc95ac72a04b5ca728ceea6008b6e7cb406d2ff3df845fe0cc79446372491
MD5 dc090b69667d2ab4f9b0931c4d7b1ad7
BLAKE2b-256 ca5e32c2cdd72fa9d9e684321506a8a34e00304f73502aea68f8f6d1dc099598

See more details on using hashes here.

File details

Details for the file lexigram_ai-0.1.5001-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_ai-0.1.5001-py3-none-any.whl
Algorithm Hash digest
SHA256 b8c2a003969d439814a08f6337d75df208591a4824f3506a99b9ade634b5ff21
MD5 d4b77b2e13d91d4d0002bf7c4577991b
BLAKE2b-256 1dbf6810a68bb0efddee25904ad1b7ee0f84f012d0356e1d8d9669c6d42348f9

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5003

1 file

This release

0.1.5001 This release

2 files

0.1.3007

1 file

0.1.3006

1 file

0.1.3005

1 file

0.1.4

2 files

0.1.2

1 file

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page