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


🚀 v1.1.0 is available. Read the Release Notes.


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.2.0.tar.gz (44.5 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.2.0-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pylemura-1.2.0.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for pylemura-1.2.0.tar.gz
Algorithm Hash digest
SHA256 21cc65ec6f72cbf31f8152a2f076e983655fc8c6e979aa208cd3909b08f8db69
MD5 63d45c94bb40d64bd3aaf41642f53c2f
BLAKE2b-256 c9ec1e3b8c3059f9b59bb41eb597195569761fb7579b2c4af3dabe0d326da3b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pylemura-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 55.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for pylemura-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 af2624eabdf06fd7b49532aae38c5e2029f7ed1e432f36fd2f59bee64355c833
MD5 889d2fe1e8388b174eb0c45aa34d3944
BLAKE2b-256 846d14d9c1c04c210e79ca0ca9606ebdcdd98847e78c901002baae05bb5a1ee2

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