🦁 Lion Framework
Language InterOperable Network
A powerful Python framework for structured AI conversations and operations
🌟 Features
- 🎯 Dynamic structured output at runtime
- 🔄 Easy composition of multi-step processes
- 🤖 Support for any model via
litellm - 🏗️ Built-in conversation management
- 🧩 Extensible architecture
- 🔍 Type-safe with Pydantic models
🚀 Quick Install
pip install lion-os
Note
the operation API is experimental and may change in future versions. Use with caution.
💡 Usage Examples
1️⃣ Simple Communication
using litellm integration
from lion import LiteiModel, Branch
# Initialize model and branch
imodel = LiteiModel(
model="openai/gpt-4o",
api_key="OPENAI_API_KEY",
temperature=0.2,
)
branch = Branch(imodel=imodel)
# Basic communication
result = await branch.communicate(
instruction="Give me ideas for FastAPI interview questions",
context="We're hiring senior engineers"
)
using lion's own service system (only supports openai / anthropic / perplexity / groq)
from lion import iModel
# Initialize model and branch
imodel = iModel(
provider="openai",
model="gpt-4o",
api_key="OPENAI_API_KEY",
temperature=0.2,
task="chat",
)
# if use anthropic
# imodel = iModel(
# provider="anthropic",
# model="claude-3-5-sonnet-20241022",
# task="messages",
# api_key="ANTHROPIC_API_KEY",
# max_tokens=500,
# )
# use perplexity
# imodel = iModel(
# provider="perplexity",
# model="llama-3.1-sonar-small-128k-online",
# task="chat/completions",
# api_key="PERPLEXITY_API_KEY",
# max_tokens=500,
# )
# use groq
# imodel = iModel(
# provider="groq",
# model="llama3-8b-8192",
# task="chat/completions",
# api_key="GROQ_API_KEY",
# max_tokens=500,
# )
branch = Branch(imodel=imodel)
# Basic communication
result = await branch.communicate(
instruction="Give me ideas for FastAPI interview questions",
context="We're hiring senior engineers"
)
2️⃣ Structured Output with Pydantic
from pydantic import BaseModel
class CodingQuestion(BaseModel):
question: str
evaluation_criteria: str
# Get structured responses
questions = await branch.operate(
instruction="Generate FastAPI coding questions",
context="Technical interview context",
operative_model=CodingQuestion
)
3️⃣ Advanced Operations (Brainstorming)
from lion.operations import brainstorm
result = await brainstorm(
instruct={
"instruction": "Design API endpoints for a todo app",
"context": "Building a modern task management system"
},
imodel=imodel,
num_instruct=3,
operative_model=CodingQuestion,
auto_run=True
)
🎯 Key Components
| Component | Description |
|---|---|
| Branch | Main conversation controller |
| MessageManager | Handles message flow and history |
| ToolManager | Manages function execution and tools |
| Operative | Structures operations and responses |
Requirements
python 3.11+ required
⭐ Star History
Metadata
Release files for lion-os 0.2.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| lion_os-0.2.9.tar.gz | 215.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lion_os-0.2.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 570.0 kB
Release files / lion_os-0.2.9.tar.gz
| Download URL | lion_os-0.2.9.tar.gz |
|---|---|
| Size | 215.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cc705ac0f5c2262fd8181391772c6a3ba20867f90dd8e6f40aa7e77e392fb9f
|
|
BLAKE2b-256 checksum How to use checksums |
21a8cabb2c610ff3debf0b8a1b7c4294638fe1dbea6efb2d7c845f8ae69b9d0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Release files / lion_os-0.2.9-py3-none-any.whl
| Download URL | lion_os-0.2.9-py3-none-any.whl |
|---|---|
| Size | 354.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36111fbc97a880b58d54e7ec54a0de1aea1a458fe30e3cfff02d4a10a77be006
|
|
BLAKE2b-256 checksum How to use checksums |
e68f4b69778680c7ca834a020ee4aa338be8c7437427f26dd3ea815a7b5abf37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Security for lion-os 0.2.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.