Skip to main content

The simplest AI agents

Project description

Ollagents

Ollama powered AI Agent Framework

Ollagents is a minimalistic python framework to build AI Agents on top of Ollama's function calling feature with the least amount of friction possible. No bloat / no learning curve. Simple, yet effective.


Getting Started

Installation

Start by installing ollagents:

# With PIP
pip install ollagents

# With UV
uv add ollagents

Tool setup

Next, you go hop into the code and start defining your tools using the tool decorator:

from ollagents import tool

@tool
def web_search(url: str):
    """Search information on a specific website via its URL"""
    pass

There are quite a few things to unpack from the code above:

  • Use the @tool decorator on your function to mark it as being a tool.
  • The function name will be directly tied to you tool visible name for the LLM (in this case, web_search)
  • The description of your tool, that will be visible by the LLM on request, is made using regular python documentation
  • Arguments, much like the function name, will also be visible by the LLM — So are their types!
    • To mark an argument as optional, use the Optional type from the typings package
  • For simplicity’s sake, it's highly recommended to always return a str from a tool.

Agent

Now that you have your tools defined, you can move on to the definition of your agent. For that we will update the previous code to import the Agent class from ollagents

from ollagents import Agent, tool
...

Next, we simply tell our agent what tool it can use:

agent = Agent(tools=[web_search()])

Optionally here you can also change the system prompt by passing a string to the system argument:

agent = Agent(tools=[web_search()], system="You are an helpful agent")

Running all together

With the Agent and the list of tools defined, you are now ready to make a request. There are a few arguments that you can pass to the agent's run function:

Argument Usage Default Value
model The model that Ollama's backend will use to fulfil your request None
prompt The prompt (a.k.a. the question) None
stream Whether to use the agent in streaming mode (requires some code adjustments) False
verbose Agent will report all tool usage, as well as the arguments used False

Here's a basic example, following our above code:

response = agent.run(
    model="qwen2.5:7b",
    prompt="Tell me more about runtime44.com"
)

Streaming Mode

As mentioned in the table above, you can use streaming mode to receive partial response from your agent. To do that you will need to modify the run section of the code to handle python generators as follows:

final_answer = ""
for part in agent.run(model="qwen2.5:7b", prompt="Tell me more about runtime44.com", stream=True):
    final_answer += part
    print(part, end="", flush=True)

[!NOTE] Here, the final_answer variable is only necessary if you want to keep the final output of the agent somewhere to reuse. If you don't plan to, you can omit it.

Examples

  1. Basic Website Parser
from ollagents import Agent, tool

@tool
def web_search(url: str);
    """Search information on a specific website"""

    from requests import request
    from markitdown import MarkItDown

    resp = request(
        method="GET",
        url=url,
    )
    if not resp or not resp.ok:
        return "Invalid URL, please try again"

    return MarkItDown().convert(resp).text_content

agent = Agent(
    tools=[web_search()]
)

response = agent.run(
    model="qwen2.5:7b",
    prompt="Tell me more about runtime44.com", 
)
print(response)

[!NOTE] This examples requires installing requests and markitdown.

Features

  1. Minimal footprint
from ollagents import Agent, tool

@tool
def your_tool_name():
    """Describe your tool in comments"""
    pass

agent = Agent(tools=[your_tool_name()])
response = agent.run(...)
  1. Fail-safe using quantum parallel validation (that's a lie, it's just a while i < X...)
  2. Streaming Response
agent.run(..., stream=True)
  1. Verbose Mode to know what your agent is doing at any time.
agent.run(..., verbose=True)
  1. Per-request model definition, in case you want to chain calls and use different models for a specific agent or a specific request

How It Works

  • To define a tool, you have to decorate your function with the @tool decorator — Nothing extremely complex here.
  • The name of your tool (that will be visible by the LLM) is going to be inferred from the name of your function. For example, calling your function web_seach will result in a tool with the same name.
  • You can describe your tool using python native doc, it will be extracted and passed to the LLM during the request. (c.f earlier examples)
  • You can override the system prompt when creating your agent:
agent = Agent(system="My custom system prompt", tools=...)
  • Typing is important, using Optional for example, will make your tool argument ... optional, meaning that if the LLM decides that it is pertinent to input something here, it will otherwise it won't. As opposed to required parameters that will always be filled by the LLM

BibTeX

@Misc{ollagents,
  title =        {Ollagents: Minimalistic framework to build AI agents powered by Ollama},
  author =       {Hugo Ventura},
  howpublished = {\url{https://github.com/hugovntr/ollagents}},
  year =         {2025}
}

This framework is subject to change (a lot), so whatever you do, don't put this in production or do anything stupid with it and blame me. From this point on, it's all on you!

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

ollagents-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

ollagents-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file ollagents-0.1.1.tar.gz.

File metadata

  • Download URL: ollagents-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.20

File hashes

Hashes for ollagents-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6aedebe9c635769c1c9aaaccb900af5dd67773438288c347aabb7ad1ae16e435
MD5 2ed6582fd08d934044145c7208868b8b
BLAKE2b-256 13850ad400f499bb559a6238ab300f8119f6cd92b20296293eafa4808207b4f1

See more details on using hashes here.

File details

Details for the file ollagents-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ollagents-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.20

File hashes

Hashes for ollagents-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0308e98ba003c16c185bde54c4cab70ce005214d4793cb257ad4c6f5aa66b57
MD5 10fe12eadfe7043b1075ca0f953a58e2
BLAKE2b-256 345c0318b001758e3406b35fbcbfc8644596053999b85537326d12bd1b83a441

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