A lightweight, zero-dependency, provider-agnostic LLM agent with tool-calling support for Anthropic, OpenAI, Gemini, and Ollama.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmadapt-0.1.0.tar.gz.
File metadata
- Download URL: llmadapt-0.1.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
221501214a9c5caca6364ecaa1caf0d4eaaacc06c7415b42e388d993c21a2fbc
|
|
| MD5 |
b6fe7cdf793af64941503f768fbcbdbd
|
|
| BLAKE2b-256 |
d126ce85e31d23d0f74bac94673fbced68884e8788d96c77250f55e8de7194be
|
File details
Details for the file llmadapt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llmadapt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03da48d7c3a40eb2d3b8370002ccd8093ee29d05362c8d63f9acc5ac9df0dbfa
|
|
| MD5 |
64f09e1d96fd9df72eaea48d95fdaa7f
|
|
| BLAKE2b-256 |
6919ec57373878908c2d8771ee63e1866cea13598851c8b9f1b658489aad65de
|