Skip to main content

llmadapt

A small, zero-dependency, provider-agnostic agent for chatting with LLMs and giving them tools. Works with Anthropic, OpenAI, Gemini, and Ollama using only the Python standard library for HTTP — no requests, no provider SDKs. v0.1.0

Install

From source (until published to PyPI):

git clone https://github.com/Shyam-Parikh-2025/llmadapt.git
cd llmadapt
pip install -e .

Once published:

pip install llmadapt

Quick start

from llmadapt import Agent

agent = Agent(
    provider="anthropic",
    model="claude-sonnet-4-6",
    api_key="sk-ant-...",  # or set ANTHROPIC_API_KEY in your environment
    system_instruction="You are a helpful assistant.",
)

print(agent.chat("What's 12 * 7?"))

Giving the agent tools

def get_weather(city: str) -> dict:
    """Look up the current weather for a city."""
    return {"city": city, "tempF": 72, "condition": "sunny"}

agent.add_tool(get_weather)
print(agent.chat("What's the weather in NYC?"))

A JSON schema is auto-generated from the function's type hints, default values, and docstring. Tool outputs are JSON-serialized automatically (plain strings pass through untouched).

Switching providers

agent.switch_api(provider="openai", model="gpt-4o", api_key="sk-...")

Limiting tool-call loops

agent.set_max_tool_iterations(20)  # default is 10

If the model gets stuck calling tools repeatedly without producing a final answer, chat() raises a RuntimeError instead of looping forever.

Supported providers

provider env var for API key notes
anthropic ANTHROPIC_API_KEY Messages API
openai OPENAI_API_KEY Chat Completions API
gemini GEMINI_API_KEY generateContent endpoint
ollama (none — local) defaults to localhost:11434
custom (none — pass directly) requires base_url + a custom_format_func you supply to chat()

Running tests

python tests/test_agent.py

Tests run entirely offline against scripted fake HTTP responses — no API key or network access required.

License

MIT

Metadata

Release files for llmadapt 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llmadapt 0.1.0
File Size Uploaded
llmadapt-0.1.0.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llmadapt 0.1.0
File Interpreter ABI Platform
llmadapt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.2 kB

Release files / llmadapt-0.1.0.tar.gz

Download URL llmadapt-0.1.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
221501214a9c5caca6364ecaa1caf0d4eaaacc06c7415b42e388d993c21a2fbc
BLAKE2b-256 checksum
How to use checksums
d126ce85e31d23d0f74bac94673fbced68884e8788d96c77250f55e8de7194be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / llmadapt-0.1.0-py3-none-any.whl

Download URL llmadapt-0.1.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03da48d7c3a40eb2d3b8370002ccd8093ee29d05362c8d63f9acc5ac9df0dbfa
BLAKE2b-256 checksum
How to use checksums
6919ec57373878908c2d8771ee63e1866cea13598851c8b9f1b658489aad65de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page