A tiny, lightweight and unintrusive library for orchestrating agentic applications.
Project description
TinyAgents
A tiny, lightweight and unintrusive library for orchestrating agentic applications.
Here's the big idea:
- 😶🌫️ Less than 500 lines of code. "I have absolutely no idea what this library is doing under the hood"
- 😨 Avoid including the entirety of PyPi in the requirements.txt
- 🚀 Minimise the need for code changes. "The library is no longer being maintained - so let's retire our application with it."
Upcoming:
- Support for deployment and execution using Ray.
- easily deploy and scale nodes in your graph as Ray Serve deployments.
- A set of callbacks for storing traces to Redis, Pub/Sub or disk.
- 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
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
tinyagents-0.1.0.tar.gz
(5.3 kB
view details)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | fac7ee1495062b06f3df332935622cd1243fb2bb1d3724ee3872b4d53d7a062f |
|
MD5 | 64ccf91d6a5e67ce1ec191e3780ab8f2 |
|
BLAKE2b-256 | 50e82e6f0f85ff7ca975330de1ceb72d8789e9134b9d38b8d3a2ab3cdaba84ed |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b23035077574dc0bc429e118b7275ea5a1507b7cf4b3570923384106719b656 |
|
MD5 | afd48b5c9c23d2d7fb0c610957232a62 |
|
BLAKE2b-256 | 8e1daebd34dcd1907e6d2023a77072357e09ef9e27c602b1d3494fa8c1e0dbaa |