Skip to main content

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.

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

pyagentkit-0.1.5.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

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

pyagentkit-0.1.5-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

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

Hashes for pyagentkit-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ba645d158a7749f3a8ea5f5af02ae42c92a1fe0b3b02c90bb49aa177f8680350
MD5 5fa042c79711340e6295e29375cd1f98
BLAKE2b-256 5197a25e7e853a5578a959515e6c5b6d8310368811f24c015db4ba122371e598

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyagentkit-0.1.5.tar.gz:

Publisher: python-publish.yml on TarikEren/pyagentkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pyagentkit-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 adaffb4556e6804f4f4441c51aac585c02dd4b7462ad70529bb75768a5a1b794
MD5 04b6c1e92f0baa0ada4532b505dc1969
BLAKE2b-256 bfea8f4454544f0720908da286a177b0393d00051deaef27983b4046cffa9ba5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyagentkit-0.1.5-py3-none-any.whl:

Publisher: python-publish.yml on TarikEren/pyagentkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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