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.

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for lexigram_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5fda94b62c746e1de4519cd035a65f4847c851e5ce30fc3db3eb637ceb4725a
MD5 692e17e5864e431d4bb483d724ce7d6e
BLAKE2b-256 7b668756832053bdc76c20d6d1199e23efd44e75975b38fd934c744162de3e24

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