The kernel layer for production AI agents - protocol-based, type-safe, zero framework lock-in
Project description
lionpride
Production-ready primitives for multi-agent workflow orchestration.
⚠️ Alpha/Experimental - API unstable. For research and development use. Originated from lionagi v0.
Features
- Model Agnostic - Built-in providers for OpenAI-compatible APIs, Anthropic, Gemini
- LNDL - Domain-specific language for LLM structured output and enhanced reasoning
- Declarative Workflows - Report/Form system for multi-step agent pipelines
- Async Native - Operation graph building, dependency-aware execution
- Modular Architecture - Protocol-based composition, zero framework lock-in
- 99%+ Test Coverage - Production-hardened with comprehensive test suites
Installation
pip install lionpride
Quick Start
import asyncio
from lionpride import Session, iModel
# Create model and session
model = iModel(provider="openai", model="gpt-4o-mini")
session = Session(default_generate_model=model)
# Create branch with model access
branch = session.create_branch(name="main")
# Conduct an operation
async def main():
from lionpride.operations.operate import OperateParams, GenerateParams
result = await session.conduct(
"operate",
branch,
params=OperateParams(
generate=GenerateParams(instruction="What is 2 + 2?")
),
)
print(result.response)
asyncio.run(main())
Core Concepts
Session & Branch
Session orchestrates messages, services, and operations. Branch is a named conversation thread with access control.
from lionpride import Session, iModel
# Session with default model
model = iModel(provider="openai", model="gpt-4o-mini")
session = Session(default_generate_model=model)
# Branch inherits access to default model
branch = session.create_branch(
name="analysis",
capabilities={"MyOutputSchema"}, # Allowed output types
)
Operations
Operations are composable building blocks for agent workflows:
from lionpride.operations.operate import operate, OperateParams, GenerateParams
# Structured output with validation
params = OperateParams(
generate=GenerateParams(
instruction="Analyze this data and return insights",
request_model=MyInsightsModel, # Pydantic model for validation
)
)
result = await operate(session, branch, params)
Services
ServiceRegistry manages models and tools with O(1) name lookup:
from lionpride import Session, iModel, ServiceRegistry
# Register multiple models
registry = ServiceRegistry()
registry.register(iModel(provider="openai", model="gpt-4o", name="gpt4"))
registry.register(iModel(provider="anthropic", model="claude-3-5-sonnet", name="claude"))
session = Session(services=registry)
branch = session.create_branch(resources={"gpt4", "claude"}) # Access to both
Declarative Workflows
Report and Form enable multi-step agent pipelines with automatic dependency resolution:
from pydantic import BaseModel
from lionpride.work import Report, flow_report
class Analysis(BaseModel):
summary: str
score: float
class MyReport(Report):
analysis: Analysis | None = None # Schema attribute
assignment: str = "topic -> analysis"
form_assignments: list[str] = ["topic -> analysis"]
report = MyReport()
report.initialize(topic="AI coding assistants")
result = await flow_report(session, report, branch=branch)
Architecture
lionpride/
├── core/ # Primitives: Element, Pile, Flow, Graph, Event
├── session/ # Session, Branch, Message management
├── services/ # iModel, Tool, ServiceRegistry, MCP integration
├── operations/ # operate, react, communicate, generate, parse
├── work/ # Declarative workflows: Report, Form, flow_report
├── rules/ # Validation rules and auto-correction
├── types/ # Spec, Operable, type system
├── lndl/ # LNDL parser and resolver
└── ln/ # Utility functions
See CLAUDE.md for detailed codebase navigation.
Documentation
- CLAUDE.md - AI agent codebase guide
- AGENTS.md - Quick reference for AI agents
- notebooks/ - Example notebooks
Roadmap
- Formal mathematical framework for agent composition
- Rust core for performance-critical paths
- Enhanced MCP (Model Context Protocol) support
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lionpride-1.0.0a2.tar.gz.
File metadata
- Download URL: lionpride-1.0.0a2.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39687e635dd5206ca3d0853b30c2a7b4f1fdf92fc275ff1f4849032177a32e42
|
|
| MD5 |
3ce3b345e6f2263f759651022dd3831d
|
|
| BLAKE2b-256 |
3c6e05878941d9be59e35b520b5fd40daa64dfa51d4aaa5a3de54ad740a42538
|
File details
Details for the file lionpride-1.0.0a2-py3-none-any.whl.
File metadata
- Download URL: lionpride-1.0.0a2-py3-none-any.whl
- Upload date:
- Size: 306.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e806626b739ecd2596b1e25addef85042194f8a05b80fc995aba9b23bf2c753c
|
|
| MD5 |
d944e5a95b2f50d7db8a16cc16b4871a
|
|
| BLAKE2b-256 |
53bbb41aee5dd45005196693a2ca4b1e61ad1b76b35096c93358097479a5d19a
|