Skip to main content

A GenAI project built with LangChain and modern Python tools

Project description

Agent LLM Service

Agent LLM Service is a robust, clean, and extensible Python library designed for executing LLM requests across multiple language models (e.g., OpenAI, Groq, Gemini). It offers reliable fallback mechanics, model round-robins, API rate-limit management, built-in tool/function-calling structures, and exponential backoff retry logic.

It is built as the core execution engine for any multi-agent system, strictly adhering to modern Python typing (Pydantic v2) and asynchronous request handling (httpx, asyncio).

Key Features

  • Execution Pool & Failover Strategy: Automatically cycle through fallback models when encountering rate limits or temporary provider issues (LlmExecutionPool).
  • Resilient Polling & Backoffs: Built-in retry with exponential backoff (LlmRunner).
  • Modular Provider Interface: Easily write adapters and unified RawLlmProvider handlers that work with OpenAI-spec endpoints.
  • Native Tool Calling Definitions: Extensively typed schemas to define custom tools (BaseTool) and dispatch LLM decisions automatically mappings to real functions (ToolRegistry).
  • Asynchronous by Default: Built utilizing async (httpx.AsyncClient) for scaling safely across multi-agent fleets.

Getting Started

Installation

Ensure you are using Python >= 3.12. Install dependencies using uv or pip:

uv add agent-llm-service 

# or you can also use with pip
# pip install agent-llm-service

Quick Usage

from agent_llm_service import LlmProviderConfig, RawLlmProvider, LlmRunner
from dotenv import load_dotenv

load_dotenv()  # Load environment variables from .env file


async def main():
    # Configure the provider (e.g., Groq via OpenAI schema)
    config = LlmProviderConfig(
        name="Groq",
        slug="groq",
        api_key_env_var="GROQ_API_KEY",
        base_url="https://api.groq.com/openai/v1",
        enabled=True,
    )

    provider = RawLlmProvider(config=[config])
    runner = LlmRunner(provider=provider)

    # Async LLM Run
    response = await runner.acall(
        model="groq/openai/gpt-oss-20b",
        messages=[{"role": "user", "content": "What is the capital of France?"}],
    )
    print(response.content)


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Documentation

Note: If not shown directly on PyPi package, try seeing in Github repo: SurajAiri/Agent-LLM-Service

Contributing

  1. Fork the repository and create an issue.
  2. Ensure you run the linter (uv run ruff check src --fix).
  3. Submit a PR.

License

MIT License.

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

agent_llm_service-0.0.4.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

agent_llm_service-0.0.4-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file agent_llm_service-0.0.4.tar.gz.

File metadata

  • Download URL: agent_llm_service-0.0.4.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for agent_llm_service-0.0.4.tar.gz
Algorithm Hash digest
SHA256 96e5fe686c2f11ad2c3a74c934aa2652b69c953b961a376d84e58ee0caafdc5e
MD5 dadff8a808328b8a064a0424b9c4c47b
BLAKE2b-256 e3a00b7650660515f748438b8837fc68ebb4e2b523aac27ed54442f94e5d07f3

See more details on using hashes here.

File details

Details for the file agent_llm_service-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_llm_service-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a53d59017ae486af940a682f2678dc9802bc54af928ac6e1a2c77176b73ec59e
MD5 1bf77b37fc58ef64ab847e7a912d3f62
BLAKE2b-256 aeafe1c024ecd27ab4451807141447a88e2f7cf74f782bd896ba551af6fa4cb4

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