Metadata-Version: 2.5
Name: lexigram-ai
Version: 0.1.3007
Summary: AI Layer for Lexigram Framework - Native LLM, Vector, RAG integration
Project-URL: Homepage, https://lexigram.dev
Project-URL: Repository, https://github.com/dbtinoy-/lexigram
Project-URL: Documentation, https://docs.lexigram.dev
Project-URL: Issues, https://github.com/dbtinoy-/lexigram/issues
Project-URL: Changelog, https://github.com/dbtinoy-/lexigram/blob/main/CHANGELOG.md
Author-email: Lexigram Framework Team <team@lexigram.dev>
Maintainer-email: Lexigram Framework Team <team@lexigram.dev>
License: MIT
License-File: LICENSE
Keywords: agents,ai,artificial-intelligence,framework,intelligence,llm,rag,vector
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: lexigram-ai-feedback>=0.1.0
Requires-Dist: lexigram-ai-llm>=0.1.0
Requires-Dist: lexigram-ai-observability>=0.1.0
Requires-Dist: lexigram-ai-rag>=0.1.0
Requires-Dist: lexigram-contracts>=0.1.0
Requires-Dist: lexigram>=0.1.1
Requires-Dist: numpy>=1.25.0
Requires-Dist: starlette>=0.28.0
Requires-Dist: typer>=0.9.0
Provides-Extra: ai
Requires-Dist: chromadb>=0.4.0; extra == 'ai'
Requires-Dist: jinja2>=3.1.0; extra == 'ai'
Requires-Dist: pgvector>=0.2.0; extra == 'ai'
Requires-Dist: pypdf>=3.0.0; extra == 'ai'
Requires-Dist: qdrant-client>=1.7.0; extra == 'ai'
Requires-Dist: scikit-learn>=1.3.0; extra == 'ai'
Requires-Dist: tiktoken>=0.5.0; extra == 'ai'
Provides-Extra: all
Requires-Dist: anthropic>=0.20.0; extra == 'all'
Requires-Dist: beautifulsoup4>=4.12.0; extra == 'all'
Requires-Dist: black>=23.0.0; extra == 'all'
Requires-Dist: chromadb>=0.4.0; extra == 'all'
Requires-Dist: jinja2>=3.1.0; extra == 'all'
Requires-Dist: joblib>=1.3.0; extra == 'all'
Requires-Dist: jsonschema>=4.0.0; extra == 'all'
Requires-Dist: lexigram-ai-feedback>=0.1.0; extra == 'all'
Requires-Dist: lexigram-ai-llm>=0.1.0; extra == 'all'
Requires-Dist: lexigram-ai-observability>=0.1.0; extra == 'all'
Requires-Dist: lexigram-ai-rag>=0.1.0; extra == 'all'
Requires-Dist: lexigram-testing>=0.1.1; extra == 'all'
Requires-Dist: lexigram-vector>=0.2.0; extra == 'all'
Requires-Dist: markdown>=3.5.0; extra == 'all'
Requires-Dist: milvus>=2.3.0; extra == 'all'
Requires-Dist: mkdocs-material>=9.0.0; extra == 'all'
Requires-Dist: mkdocs>=1.4.0; extra == 'all'
Requires-Dist: mypy>=1.0.0; extra == 'all'
Requires-Dist: numpy>=1.25.0; extra == 'all'
Requires-Dist: ollama>=0.1.0; extra == 'all'
Requires-Dist: openai>=1.0.0; extra == 'all'
Requires-Dist: pgvector>=0.2.0; extra == 'all'
Requires-Dist: pinecone-client>=2.2.0; extra == 'all'
Requires-Dist: pre-commit>=3.0.0; extra == 'all'
Requires-Dist: psycopg[binary]>=3.1.0; extra == 'all'
Requires-Dist: pypdf>=3.0.0; extra == 'all'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'all'
Requires-Dist: pytest-cov>=4.0.0; extra == 'all'
Requires-Dist: pytest-mock>=3.10.0; extra == 'all'
Requires-Dist: pytest>=8.0.0; extra == 'all'
Requires-Dist: pyyaml>=6.0; extra == 'all'
Requires-Dist: qdrant-client>=1.7.0; extra == 'all'
Requires-Dist: redis>=5.0.0; extra == 'all'
Requires-Dist: ruff>=0.1.0; extra == 'all'
Requires-Dist: scikit-learn>=1.3.0; extra == 'all'
Requires-Dist: scipy>=1.11.0; extra == 'all'
Requires-Dist: sentence-transformers>=2.2.0; extra == 'all'
Requires-Dist: tiktoken>=0.5.0; extra == 'all'
Requires-Dist: weaviate-client>=3.20.0; extra == 'all'
Requires-Dist: xgboost>=2.0.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Requires-Dist: types-beautifulsoup4>=4.12.0; extra == 'dev'
Requires-Dist: types-pillow>=9.0.0; extra == 'dev'
Requires-Dist: types-pyyaml>=6.0; extra == 'dev'
Requires-Dist: types-requests>=2.31.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.0.0; extra == 'docs'
Requires-Dist: mkdocs>=1.4.0; extra == 'docs'
Provides-Extra: feedback
Requires-Dist: lexigram-ai-feedback>=0.1.0; extra == 'feedback'
Provides-Extra: llm
Requires-Dist: anthropic>=0.20.0; extra == 'llm'
Requires-Dist: lexigram-ai-llm>=0.1.0; extra == 'llm'
Requires-Dist: ollama>=0.1.0; extra == 'llm'
Requires-Dist: openai>=1.0.0; extra == 'llm'
Requires-Dist: openrouter>=0.1.0; extra == 'llm'
Provides-Extra: llm-utils
Requires-Dist: jinja2>=3.1.0; extra == 'llm-utils'
Requires-Dist: redis>=5.0.0; extra == 'llm-utils'
Requires-Dist: tiktoken>=0.5.0; extra == 'llm-utils'
Provides-Extra: observability
Requires-Dist: lexigram-ai-observability>=0.1.0; extra == 'observability'
Provides-Extra: rag
Requires-Dist: beautifulsoup4>=4.12.0; extra == 'rag'
Requires-Dist: lexigram-ai-rag>=0.1.0; extra == 'rag'
Requires-Dist: markdown>=3.5.0; extra == 'rag'
Requires-Dist: opencv-python-headless>=4.8.0; extra == 'rag'
Requires-Dist: pillow>=10.0.0; extra == 'rag'
Requires-Dist: pypdf>=3.0.0; extra == 'rag'
Requires-Dist: sentence-transformers>=2.2.0; extra == 'rag'
Provides-Extra: test
Requires-Dist: jsonschema>=4.0.0; extra == 'test'
Requires-Dist: lexigram-testing>=0.1.1; extra == 'test'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'test'
Requires-Dist: pytest-cov>=4.0.0; extra == 'test'
Requires-Dist: pytest-mock>=3.10.0; extra == 'test'
Requires-Dist: pytest>=8.0.0; extra == 'test'
Requires-Dist: pyyaml>=6.0; extra == 'test'
Provides-Extra: vector
Requires-Dist: chromadb>=0.4.0; extra == 'vector'
Requires-Dist: lexigram-vector>=0.2.0; extra == 'vector'
Requires-Dist: milvus>=2.3.0; extra == 'vector'
Requires-Dist: pgvector>=0.2.0; extra == 'vector'
Requires-Dist: pinecone-client>=2.2.0; extra == 'vector'
Requires-Dist: psycopg[binary]>=3.1.0; extra == 'vector'
Requires-Dist: qdrant-client>=1.7.0; extra == 'vector'
Requires-Dist: weaviate-client>=3.20.0; extra == 'vector'
Description-Content-Type: text/markdown

# Give AI a pattern to follow

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

[![PyPI version](https://img.shields.io/pypi/v/lexigram-ai?color=%2334D058&label=pypi%20package)](https://pypi.org/project/lexigram-ai/)
[![Python versions](https://img.shields.io/pypi/pyversions/lexigram-ai?color=%2334D058)](https://pypi.org/project/lexigram-ai/)
[![License](https://img.shields.io/pypi/l/lexigram-ai?color=%2334D058)](https://github.com/dbtinoy-/lexigram-ai-experimental/blob/main/LICENSE)

![Lexigram AI demo](docs/gifs/hero/lexigram-hero.gif)

`lexigram-ai` is the AI layer of the [lexigram framework](https://lexigram.dev): 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](https://docs.lexigram.dev)

## install

```bash
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

```python
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.

```text
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 [lexigram-ai-experimental](https://github.com/dbtinoy-/lexigram-ai-experimental) — 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

- full docs → [docs.lexigram.dev](https://docs.lexigram.dev)
- the stable core → [lexigram](https://github.com/dbtinoy-/lexigram)
- the AI family → [lexigram-ai-experimental](https://github.com/dbtinoy-/lexigram-ai-experimental)