Skip to main content

A tiny, lightweight and unintrusive library for orchestrating agentic applications.

Project description

TinyAgents

drawing

A tiny, lightweight and unintrusive library for orchestrating agentic applications.

Here's the big idea:

  1. 😶‍🌫️ Less than 500 lines of code. "I have absolutely no idea what this library is doing under the hood"
  2. 😨 Avoid including the entirety of PyPi in the requirements.txt
  3. 🚀 Minimise the need for code changes. "The library is no longer being maintained - so let's retire our application with it."

Upcoming:

  1. Support for deployment and execution using Ray.
    • easily deploy and scale nodes in your graph as Ray Serve deployments.
  2. A set of callbacks for storing traces to Redis, Pub/Sub or disk.
  3. A tool for visualising what is happening within your graphs

Installation

pip install https://github.com/adam-h-ds/tinyagents.git

How it works!

Define your graph using standard operators

Parallelisation

from tinyagents import chainable

@chainable
def tool1(inputs: dict):
    return ...

@chaianble
def tool2(inputs: dict):
    return ...

@chainable
class Agent:
    def __init__(self):
        ...

    def run(self, inputs: list):
        return ...

# run `tool1` and `tool2` in parallel, then pass outputs to `Agent`
graph = (tool1 & tool2) | Agent()
executor = graph.compile()

executor.execute("Hello!")

Branching

jailbreak_check = ...
agent1 = ...
agent2 = ...
guardrail = ...

def my_router(inputs: str):
    if inputs == "jailbreak_attempt":
        return agent2.name

    return agent1.name

# check for jailbreaks, then run either `agent1` or `agent2`, then finally run `guardrail`
graph = jailbreak_check | (agent1 / agent2).bind_router(my_router) | guardrail

print(graph)

## jailbreak_check -> ConditionalBranch(agent1, agent2) -> guardrail

Looping

from tinyagents import loop

agent1 = ...
agent2 = ...
agent3 = ...
guardrail = ...

# run at most 3 iterations between `agent1` and `agent2`, then pass to `agent3` and finally `guardrail`.
graph = loop(agent1, agent2, max_iter=3) | agent3 | guardrail

print(graph)

## Recursive(agent1, agent2) -> agent3 -> guardrail

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

tinyagents-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

tinyagents-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file tinyagents-0.1.0.tar.gz.

File metadata

  • Download URL: tinyagents-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1022-azure

File hashes

Hashes for tinyagents-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fac7ee1495062b06f3df332935622cd1243fb2bb1d3724ee3872b4d53d7a062f
MD5 64ccf91d6a5e67ce1ec191e3780ab8f2
BLAKE2b-256 50e82e6f0f85ff7ca975330de1ceb72d8789e9134b9d38b8d3a2ab3cdaba84ed

See more details on using hashes here.

File details

Details for the file tinyagents-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tinyagents-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1022-azure

File hashes

Hashes for tinyagents-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b23035077574dc0bc429e118b7275ea5a1507b7cf4b3570923384106719b656
MD5 afd48b5c9c23d2d7fb0c610957232a62
BLAKE2b-256 8e1daebd34dcd1907e6d2023a77072357e09ef9e27c602b1d3494fa8c1e0dbaa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page