No project description provided
Project description
🦁 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)
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,
# )
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
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 lion_os-0.2.3.tar.gz.
File metadata
- Download URL: lion_os-0.2.3.tar.gz
- Upload date:
- Size: 200.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc0783e2d83aa17f1b67f9235aecb5f7d62d2905af79f7c97767d0658a5c587e
|
|
| MD5 |
7415a92de590d596b6f0da8193a9780f
|
|
| BLAKE2b-256 |
06cf352e8215ed8ef02644e2d49b268b4e70e92282fa6c872f341821789e0a5e
|
File details
Details for the file lion_os-0.2.3-py3-none-any.whl.
File metadata
- Download URL: lion_os-0.2.3-py3-none-any.whl
- Upload date:
- Size: 330.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.7 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26c843f5f9faa7830befd91408059d7e0b658e816d822ecc5421d8f8218e6dae
|
|
| MD5 |
2a418e5b35a87dda1d33933cc7272dae
|
|
| BLAKE2b-256 |
e6c96b22bc84fe1c69c27afd7a84ca75a31cc03b376c315da3c7217649a2cc13
|