Prime: a barebones library for agents. Agents write python code to call tools or orchestrate other agents.
Project description
<<<<<<< HEAD
prime
Prime: a solana python library for creating new agents. Agents write python code to call tools or orchestrate other agents.
🤗 prime - a smol library to build great agents!
prime is a library that enables you to run powerful agents in a few lines of code. It offers:
✨ Simplicity: the logic for agents fits in ~thousand lines of code (see agents.py). We kept abstractions to their minimal shape above raw code!
🧑💻 First-class support for Code Agents, i.e. agents that write their actions in code (as opposed to "agents being used to write code"). To make it secure, we support executing in sandboxed environments via E2B.
- On top of this
CodeAgentclass, we still support the standardToolCallingAgentthat writes actions as JSON/text blobs.
🤗 Hub integrations: you can share and load tools to/from the Hub, and more is to come!
🌐 Support for any LLM: it supports models hosted on the Hub loaded in their transformers version or through our inference API, but also supports models from OpenAI, Anthropic and many others via our LiteLLM integration.
Quick demo
First install the package.
pip install prime-agents-py
Then define your agent, give it the tools it needs and run it!
from prime import CodeAgent, DuckDuckGoSearchTool, HfApiModel
agent = CodeAgent(tools=[DuckDuckGoSearchTool()], model=HfApiModel())
agent.run("How many seconds would it take for a leopard at full speed to run through Pont des Arts?")
https://github.com/user-attachments/assets/cd0226e2-7479-4102-aea0-57c22ca47884
Code agents?
In our CodeAgent, the LLM engine writes its actions in code. This approach is demonstrated to work better than the current industry practice of letting the LLM output a dictionary of the tools it wants to calls: uses 30% fewer steps (thus 30% fewer LLM calls)
and reaches higher performance on difficult benchmarks. Head to our high-level intro to agents to learn more on that.
Especially, since code execution can be a security concern (arbitrary code execution!), we provide options at runtime:
- a secure python interpreter to run code more safely in your environment
- a sandboxed environment using E2B.
How smol is it really?
We strived to keep abstractions to a strict minimum: the main code in agents.py is only ~1,000 lines of code.
Still, we implement several types of agents: CodeAgent writes its actions as Python code snippets, and the more classic ToolCallingAgent leverages built-in tool calling methods.
By the way, why use a framework at all? Well, because a big part of this stuff is non-trivial. For instance, the code agent has to keep a consistent format for code throughout its system prompt, its parser, the execution. So our framework handles this complexity for you. But of course we still encourage you to hack into the source code and use only the bits that you need, to the exclusion of everything else!
How strong are open models for agentic workflows?
We've created CodeAgent instances with some leading models, and compared them on this benchmark that gathers questions from a few different benchmarks to propose a varied blend of challenges.
Find the benchmarking code here for more detail on the agentic setup used, and see a comparison of using LLMs code agents compared to vanilla (spoilers: code agents works better).
This comparison shows that open source models can now take on the best closed models!
Citing prime
If you use prime in your publication, please cite it by using the following BibTeX entry.
@Misc{prime,
title = {`prime`: The easiest way to build efficient agentic systems.},
author = {Aymeric Roucher and Thomas Wolf and Leandro von Werra and Erik Kaunismäki},
howpublished = {\url{https://github.com/huggingface/prime}},
year = {2025}
}
7f9d20c (Initial commit)
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
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 prime_agents_py-1.1.0.dev0.tar.gz.
File metadata
- Download URL: prime_agents_py-1.1.0.dev0.tar.gz
- Upload date:
- Size: 75.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c934596d86db5f8193083cc178f5cf7259547f93ee282367d1b59df73e760fa9
|
|
| MD5 |
721fb0d5f922ab640f1d9a8688c043ae
|
|
| BLAKE2b-256 |
e20b1d1076762b96823a1da3f3c0855b384d3893b367d02fd446246a8ea6cf5b
|
File details
Details for the file prime_agents_py-1.1.0.dev0-py3-none-any.whl.
File metadata
- Download URL: prime_agents_py-1.1.0.dev0-py3-none-any.whl
- Upload date:
- Size: 63.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fa88857762eae1330dca831020ce5d92f3e59c5d8f81f810992c49b166763e0
|
|
| MD5 |
b0b0fb39a4bc72b9694372f82ad0ec4e
|
|
| BLAKE2b-256 |
298f54f945d4bba6e59efb963970eebc62b32513572ee1e70dae9a8e33ab21f1
|