Skip to main content

No project description provided

Project description

🦁 Lion Framework

Language InterOperable Network

A powerful Python framework for structured AI conversations and operations

Python 3.11+ PyPI version PyPI - Downloads

🌟 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

Star History Chart

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lion_os-0.2.6.tar.gz (215.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lion_os-0.2.6-py3-none-any.whl (354.0 kB view details)

Uploaded Python 3

File details

Details for the file lion_os-0.2.6.tar.gz.

File metadata

  • Download URL: lion_os-0.2.6.tar.gz
  • Upload date:
  • Size: 215.3 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

Hashes for lion_os-0.2.6.tar.gz
Algorithm Hash digest
SHA256 f40cdf86564458de29a73b3b64a65acca81558d98aca5cfa0aed4a6a209af0a2
MD5 0f0d3af12772ee0a2fc0db48d0866cde
BLAKE2b-256 92556dea792256d58f1f2a6bccbae80f2949d9ee0455d07a98345afa9782d087

See more details on using hashes here.

File details

Details for the file lion_os-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: lion_os-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 354.0 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

Hashes for lion_os-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 7bd74873f8b633871432dd41dce382a1858f0ef080f560d9244eb7229445c4fe
MD5 445ef1e03b4c8c97ef0327f2b8f3da75
BLAKE2b-256 ccbb62d45720ba5a9b8d08b5767efe9aaa63e78d06c1f6a522befce24617187f

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