Skip to main content

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

Project description

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

Project details


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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for lexigram_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 44b9f25a50731c9c5af08189870052060599f273f3c2c9c18470a32bf09079fd
MD5 55e733ededc39956cd1188f808f3abff
BLAKE2b-256 3b5d2b0c61e5ae21ac22b2aaa7f6481fc59c1b3dfcfc8a6d1d383b8058fc0beb

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