Skip to main content

lexigram-ai

AI Layer for Lexigram Framework - Native LLM, Vector, RAG integration


Overview

lexigram-ai is the AI orchestration layer for the Lexigram Framework. It is a thin coordinator package that wires together independent AI sub-packages (lexigram-ai-llm, lexigram-ai-rag, lexigram-ai-agents, etc.) via the framework's DI container and entry-point discovery, and exposes a single AIModule entry point for application composition. Zero-config usage starts with sensible defaults.

Full documentation: docs.lexigram.dev

Install

uv add lexigram-ai
# Optional extras
uv add "lexigram-ai[llm,vector,rag,governance,observability]"

Quick Start

from lexigram import Application
from lexigram.di.module import Module, module

from lexigram.ai import AIModule

@module(imports=[AIModule.configure()])
class AppModule(Module):
    pass

app = Application(modules=[AppModule])
if __name__ == "__main__":
    app.run()

Configuration

Zero-config usage: Call AIModule.configure() with no arguments to use defaults.

Option 1 — YAML file

# application.yaml
ai:
  llm:
    default_provider: "openai"
    openai:
      api_key: "${OPENAI_API_KEY}"
  rag:
    enabled: true
  governance:
    enabled: true
    monthly_budget: 1000.0

Option 2 — Profiles + Environment Variables (recommended)

export LEX_PROFILE=production
# Environment variables for each field

Option 3 — Python

from lexigram.ai.config import AIConfig
from lexigram.ai import AIModule

config = AIConfig(...)
AIModule.configure(config)

Config reference

Field Default Env var Description
enabled True LEX_AI__ENABLED Global AI feature toggle
llm None LEX_AI_LLM__* LLM provider config
vector None LEX_AI__VECTOR__* Vector store config
rag None LEX_AI__RAG__* RAG pipeline config
governance default LEX_AI__GOVERNANCE__* Policy enforcement config
observability default LEX_AI__OBSERVABILITY__* Tracing and metrics config
subsystems {} Config for third-party entry-point subsystems

Module Factory Methods

Method Description
AIModule.configure(config) Configure with explicit config
AIModule.stub() Minimal config for testing

Key Features

  • AI orchestration: Thin coordinator wiring all AI sub-packages via DI
  • Entry-point discovery: Discovers sub-packages via lexigram.ai.subsystems entry points
  • Multi-provider support: Integrates LLM, RAG, agents, memory, governance, and observability
  • Production security: Validates API keys in production environments

Testing

async with Application.boot(modules=[AIModule.stub()]) as app:
    # your test code
    ...

Key Source Files

File What it contains
src/lexigram/ai/__init__.py Lazy-loaded public API: AIModule, AIProvider, AIConfig
src/lexigram/ai/module.py AIModule.configure() and AIModule.stub()
src/lexigram/ai/config.py AIConfig and get_subsystem_config()
src/lexigram/ai/di/provider.py AIProvider — registers and boots sub-providers
src/lexigram/ai/exceptions.py AIError base exception

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

lexigram_ai-0.1.3005-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for lexigram_ai-0.1.3005-py3-none-any.whl
Algorithm Hash digest
SHA256 e79d26659837056ca94603d6004876a9e3d10fd9931d4a2d897c50d36387a64b
MD5 c948576760d5b34fa09b06418b1ee42a
BLAKE2b-256 cc1b95848f12d414a7f8b28dff74508f54322f424f3d415894307c6baecfac52

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