Skip to main content

Provider-agnostic agentic AI runtime for Python — Python portage of lemura

Project description

pylemura

A provider-agnostic, premium agentic AI runtime for Python.

PyPI version license docs build


pylemura is a robust, provider-agnostic Python package designed to encapsulate a full agentic AI runtime. It simplifies the complex orchestration of LLMs, tools, and context management into a single, cohesive interface. It is the official Python portage of lemura.

✨ Key Features

  • 🧠 Dynamic Skill Market: Switch skills on/off at runtime via tags, names, or tool dependencies.
  • 🗺️ Continuation Planning: Multi-step tool chains with parallel execution and conditional logic.
  • 🎯 Intelligent Goal Maintenance: LLM-powered sub-goal decomposition and status tracking.
  • 🔌 MCP Support: Native Model Context Protocol integration for connecting to external tool servers.
  • 🛡️ Tool Firewall: Fully integrated ask/accept/deny policy layer for security.
  • ⚡ Parallel Tool Calls: Execute independent tools concurrently for reduced latency.
  • 🧹 Summary Injection: Ensures the model never "forgets" what was compressed away.
  • 📊 Enhanced Observability: Detailed tracing, token tracking, and execution budget enforcement.
  • 🌊 Native Streaming: Full async generator support for token-by-token completion.
  • 📦 Zero Dependencies: Core runtime runs on the Python standard library only.

🚀 Install

pip install pylemura

⚙️ Environment Variables

The built-in OpenAICompatibleAdapter can be configured using environment variables. To load them from a .env file, you can use python-dotenv:

pip install python-dotenv

Then at the very top of your entry point:

from dotenv import load_dotenv
load_dotenv()

Create a .env file in your project root:

# Provider Configuration (OpenAI, Groq, Together, Ollama, etc.)
LEMURA_API_KEY=your_api_key_here
LEMURA_BASE_URL=https://api.openai.com/v1
LEMURA_MODEL=gpt-4o-mini

# Fallbacks (Lemura also checks standard OpenAI variables)
OPENAI_API_KEY=your_api_key_here
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o-mini

⚡ Quick Start

import asyncio
from pylemura import SessionManager, OpenAICompatibleAdapter

async def main():
    adapter = OpenAICompatibleAdapter(
        base_url="https://api.openai.com/v1",
        api_key="your_api_key_here",
        default_model="gpt-4o-mini"
    )

    session = SessionManager(
        adapter=adapter,
        model="gpt-4o-mini",
        max_tokens=100000,
    )

    response = await session.run("What is lemura?")
    print(response)

if __name__ == "__main__":
    asyncio.run(main())

🧠 Core Concepts

Explore the architecture and advanced capabilities of lemura at lemura.makix.fr:

  • 🏁 Getting Started — Fundamental setup and concepts.
  • 🧹 Context Management — Advanced compression strategies.
  • 🔌 Adapters — Connecting to OpenAI, Groq, Anthropic, and more.
  • 🛠️ Tools and Skills — Extending agent capabilities.
  • 🎛️ Media Bridge — ASR, TTS, vision, and image generation.
  • Advanced Execution — Goal planning and continuation.

📦 API Overview

Component Description
SessionManager The main entry point orchestrating the ReAct loop and tools.
ContextManager Manages the conversation history using compression strategies.
OpenAICompatibleAdapter Reference adapter for OpenAI, Groq, Together, etc.
ToolRegistry Registers and executes tools for the agent.
SkillInjector Loads and formats YAML/Markdown skills into system prompts.
DefaultLogger Colorized logger with Problem/Hints metadata support.

🪵 Logging and Tracing

pylemura features a premium, structured logging system designed for developer experience. It provides colorized output and actionable hints for errors.

from pylemura import SessionManager, DefaultLogger, LogLevel

logger = DefaultLogger()
logger.set_level(LogLevel.DEBUG) # Set to show trace-level information

session = SessionManager(
    adapter=adapter,
    model="gpt-4o-mini",
    max_tokens=100000,
    logger=logger # Inject the logger
)

🔌 Provider Adapters

pylemura interacts with LLMs exclusively through the IProviderAdapter interface, ensuring zero lock-in.

Adapter Status Description
OpenAICompatibleAdapter ✅ Built-in Wrapper for OpenAI and API-compatible endpoints.

🤝 Contributing

We welcome contributions! Please refer to the TypeScript version's guidelines for general principles.

📄 License

Distributed under the MIT License. See LICENSE for more information.

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

pylemura-1.0.0.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

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

pylemura-1.0.0-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file pylemura-1.0.0.tar.gz.

File metadata

  • Download URL: pylemura-1.0.0.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for pylemura-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d9a3e54932f5f67342b5e15103b65592e3928cf85db877139ae2368b60113a69
MD5 791a40371790aac67d28375758bd2d7d
BLAKE2b-256 eb7f59ca16d42ae79160c6fef0e3fbe0ac20636cb78e002be801506d0ab7d8bb

See more details on using hashes here.

File details

Details for the file pylemura-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pylemura-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for pylemura-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e61b5817d8d73c2758ff027e6401912fa468fc9c92ab51928edf5b003b768df6
MD5 9f30a4b0b9e911766ba5ac514dbd6eb4
BLAKE2b-256 7c4ff4bc8e9f4cd45667b6588f562cfd10032620804013e9d700ce5699d901b9

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