Lite Package (BYO-LLM)
Lightweight agent framework without heavy dependencies
The praisonaiagents.lite subpackage provides a minimal agent framework that lets you bring your own LLM client — no litellm dependency and minimal memory.
from praisonaiagents import Agent
from praisonaiagents.lite import LiteAgent, create_openai_llm_fn
agent = Agent(name="assistant", instructions="You are a helpful assistant.")
llm_fn = create_openai_llm_fn(model="gpt-4o-mini")
agent = LiteAgent(
name="MyAgent",
llm_fn=llm_fn,
instructions="You are a helpful assistant.",
)
agent.chat("Hello!")The user sends a chat message; LiteAgent calls your LLM function with minimal framework overhead.
How It Works
Quick Start
- Create a lite agent
python from praisonaiagents.lite import LiteAgent, create_openai_llm_fn llm_fn = create_openai_llm_fn(model="gpt-4o-mini") agent = LiteAgent( name="MyAgent", llm_fn=llm_fn, instructions="You are a helpful assistant.", ) response = agent.chat("Hello!") print(response) - Add tools
python from praisonaiagents.lite import tool @tool def add_numbers(a: int, b: int) -> int: """Add two numbers together.""" return a + b agent = LiteAgent(name="ToolAgent", llm_fn=llm_fn, tools=[add_numbers])
Components
LiteAgent
The main agent class with thread-safe chat history:
from praisonaiagents.lite import LiteAgent
agent = LiteAgent(
name="MyAgent",
llm_fn=my_llm_function,
instructions="System instructions",
tools=[my_tool] # Optional tools
)
# Chat
response = agent.chat("Hello")
# Access chat history (thread-safe)
print(agent.chat_history)
# Clear history
agent.clear_history()Custom LLM Functions
Bring your own LLM by providing a function that takes messages and returns a string:
def my_custom_llm(messages):
"""
Args:
messages: List of dicts with 'role' and 'content'
Returns:
str: The assistant's response
"""
# Your LLM implementation here
return "Response from my LLM"
agent = LiteAgent(name="Agent", llm_fn=my_custom_llm)Built-in LLM Adapters
OpenAI Adapter
from praisonaiagents.lite import create_openai_llm_fn
# Requires OPENAI_API_KEY environment variable
llm_fn = create_openai_llm_fn(
model="gpt-4o-mini",
temperature=0.7,
max_tokens=1000
)Anthropic Adapter
from praisonaiagents.lite import create_anthropic_llm_fn
# Requires ANTHROPIC_API_KEY environment variable
llm_fn = create_anthropic_llm_fn(
model="claude-3-5-sonnet-20241022",
max_tokens=1000
)Tools
Define tools using the @tool decorator:
from praisonaiagents.lite import LiteAgent, tool
@tool
def add_numbers(a: int, b: int) -> int:
"""Add two numbers together."""
return a + b
@tool
def get_weather(city: str) -> str:
"""Get the weather for a city."""
return f"Weather in {city}: Sunny, 72°F"
agent = LiteAgent(
name="ToolAgent",
llm_fn=llm_fn,
tools=[add_numbers, get_weather]
)
# Execute tools directly
result = agent.execute_tool("add_numbers", a=5, b=3)
print(result.output) # 8
print(result.success) # TrueLiteTask
For structured task execution:
from praisonaiagents.lite import LiteAgent, LiteTask
agent = LiteAgent(name="Worker", llm_fn=llm_fn)
task = LiteTask(
description="Summarize the following text",
agent=agent,
expected_output="A brief summary"
)
result = task.execute(context="Long text to summarize...")
print(result)Thread Safety
LiteAgent uses locks for thread-safe operations:
import threading
from praisonaiagents.lite import LiteAgent
agent = LiteAgent(name="ThreadSafe", llm_fn=llm_fn)
def worker(prompt):
response = agent.chat(prompt)
print(f"Response: {response}")
# Safe to use from multiple threads
threads = [
threading.Thread(target=worker, args=(f"Question {i}",))
for i in range(5)
]
for t in threads:
t.start()
for t in threads:
t.join()Memory Efficiency
The lite package uses significantly less memory than the full package:
| Package | Memory Usage |
|---|---|
| praisonaiagents (full) | ~93MB |
| praisonaiagents.lite | ~5MB |
When to Use Lite
Use the lite package when:
- You want minimal dependencies
- You have your own LLM client
- Memory usage is critical
- You need fast startup time
- You’re building a custom integration
Use the full package when:
- You need multi-provider support via litellm
- You want automatic model routing
- You need advanced features (memory, knowledge, etc.)
Best Practices
Use lite when you own the LLM client
The lite subpackage suits custom integrations that call OpenAI or Anthropic directly.
Install full package for multi-provider routing
Switch to the full SDK when you need litellm, memory, knowledge, or automatic model routing.
Benchmark startup in your environment
Measure import time and memory on your deployment target — lite shines on edge and serverless.
Pin versions in production
Lite and full packages share core protocols — pin both SDK and wrapper versions together.