Agent toolkit for Ollama
Project description
PyAgentKit
Lightweight library for creating tool-enabled AI agents using Ollama. Including the ones that do not have tool calling capabilities.
- Refer to USAGE.md for usage details.
Why this exists
- To give models which cannot produce structured tool calls a way to call custom made Python tooling.
Features
- Works with models that have no native tool calling
- Easy, simple tool creation and robust execution loop
- Schema validation for tool inputs
- Structured and validated agent responses
Installation
pip install pyagentkit
Example
from ollama_agentkit import Agent, tool, AgentResponse, configure_logging
# For configuring agent logging
configure_logging()
# Custom output class to manipulate LLM output
class CustomOutput(AgentResponse):
sum_result: int
agent = Agent(
# Works with any LLM's locally downloaded in your ollama server
llm_name="qwen2.5-coder:7b",
# Custom response models are allowed for responses
response_model=CustomOutput
)
def sum_tool(n1: int, n2: int):
"""Adds two numbers""" # All tooling must have a one-liner docstring that defines what the function does
# Every tool must return a `ToolResult` object
return ToolResult(
return_value=ToolReturnValue.success, # Status of the return | Can be either success, error or fatal.
# Affects how the tool call is processed.
content=f"Result: {n1 + n2}" # The part which the agent will read
)
agent.add_tool(sum_tool)
# Messages get printed during the response handling
result = agent.handle_response(prompt="What is 2 + 2")
# Custom output class fields can be accessed as such
print(result.sum_result)
Design goals
- Simple to use
- Model-agnostic where possible
- Strict validation
- Clear separation of agent logic and application logic
Limitations
- Tool reliability depends on prompt and model instruction-following quality
- Some models may need stronger prompting
- Long tool chains may need retry logic or guardrails
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
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 pyagentkit-0.1.5.tar.gz.
File metadata
- Download URL: pyagentkit-0.1.5.tar.gz
- Upload date:
- Size: 45.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba645d158a7749f3a8ea5f5af02ae42c92a1fe0b3b02c90bb49aa177f8680350
|
|
| MD5 |
5fa042c79711340e6295e29375cd1f98
|
|
| BLAKE2b-256 |
5197a25e7e853a5578a959515e6c5b6d8310368811f24c015db4ba122371e598
|
Provenance
The following attestation bundles were made for pyagentkit-0.1.5.tar.gz:
Publisher:
python-publish.yml on TarikEren/pyagentkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyagentkit-0.1.5.tar.gz -
Subject digest:
ba645d158a7749f3a8ea5f5af02ae42c92a1fe0b3b02c90bb49aa177f8680350 - Sigstore transparency entry: 1216442750
- Sigstore integration time:
-
Permalink:
TarikEren/pyagentkit@bea91f68165d4692d35ec236b97d348bacf5b0c6 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/TarikEren
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@bea91f68165d4692d35ec236b97d348bacf5b0c6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyagentkit-0.1.5-py3-none-any.whl.
File metadata
- Download URL: pyagentkit-0.1.5-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adaffb4556e6804f4f4441c51aac585c02dd4b7462ad70529bb75768a5a1b794
|
|
| MD5 |
04b6c1e92f0baa0ada4532b505dc1969
|
|
| BLAKE2b-256 |
bfea8f4454544f0720908da286a177b0393d00051deaef27983b4046cffa9ba5
|
Provenance
The following attestation bundles were made for pyagentkit-0.1.5-py3-none-any.whl:
Publisher:
python-publish.yml on TarikEren/pyagentkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyagentkit-0.1.5-py3-none-any.whl -
Subject digest:
adaffb4556e6804f4f4441c51aac585c02dd4b7462ad70529bb75768a5a1b794 - Sigstore transparency entry: 1216442838
- Sigstore integration time:
-
Permalink:
TarikEren/pyagentkit@bea91f68165d4692d35ec236b97d348bacf5b0c6 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/TarikEren
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@bea91f68165d4692d35ec236b97d348bacf5b0c6 -
Trigger Event:
release
-
Statement type: