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 sync  # or `pip install -e .`

Quick Usage

from agent_llm_service import (
    LlmProviderConfig, 
    RawLlmProvider, 
    LlmRunner
)

# 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/llama3-8b-8192",
    messages=[{"role": "user", "content": "What is the capital of France?"}],
)
print(response.content)

Documentation

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.1.tar.gz (11.9 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.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agent_llm_service-0.0.1.tar.gz
Algorithm Hash digest
SHA256 727518f5238275606b14bf3a369773db6e07cb636d687835429f63a4386c30e6
MD5 1487bd60e21d8370e0d6d5ccf4da0b8a
BLAKE2b-256 bc6d7f13150af66a5f22c1520e5999f26ec6bd811db9639e38cf64c7c0fbfff7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agent_llm_service-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27b6e9989ebc742a7c8d8d754325ead4bebcfb2b40e4fbaabaf289b3ed5f2bf1
MD5 530392241f571b3b67f0bb3e6bce0837
BLAKE2b-256 e6c841235cd78e4be2cdcb73e0b58e9b8e097936f8131b71d90ac25307e3260b

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