AI Agents as DAGs - Directed Acyclic Graphs
Project description
DAGent - Directed Acyclic Graphs (DAGs) as AI Agents
DAGent is a Python library to create AI Agents without overhead
Quickstart
Install the lib
pip install dagent
DAGent Diagram
graph TD
A[Function Node] --> B[Decision Node]
B --> C[Function Node]
B --> E[Function Node]
D --> F[Function Node]
E --> G[Decision Node]
F --> H[Function Node]
G --> K[Function Node]
G -- "Pick Function to Run" --> I[Function Node]
G --> J[Function Node]
I --> L[Function Node]
J --> M[Function Node]
K --> N[Function Node]
K -- "Run Both " --> S[Function Node]
%% Additional annotations
B -- "Use a Function as a tool" --> D[Function Node]
The idea behind dagent is to structure AI agents in to a workflow. This is done through setting each function up as a node in a graph.
The agentic behavior is through the inferring of what function to run through the use of LLMs which is abstracted by a "Decision Node".
DAGent basics
DecisionNode
- This is where the llm picks a function to run from given options
- The
.compile()method autogenerates and saves tool descriptions under Tool. Run with paramforce_load=Trueif there are errors or if an option of tool changes - These tool/function descriptions get generated in
FunctionNode
- Runs a python function
- Can be attached to a
DecisionNodeto be treated as a tool and allow an LLM to choose which function to run
Example Usage
See dagent/examples/simple_agent.py for more info
Using Different Models
DAGent supports using different LLM models for inference and tool description generation. You can specify the model when calling call_llm or call_llm_tool, or when compiling the DecisionNode.
For example, to use the groq/llama3-70b-8192 model:
# Using groq with decision node
decision_node1 = DecisionNode('groq/llama3-70b-8192')
# Using ollama with decision node
decision_node2 = DecisionNode('ollama_chat/mistral', api_base="http://localhost:11434")
# Call llm function
output = decision_node2.run(messages=[{'role': 'user', 'content': 'add the numbers 2 and 3'}])
Other things to know
prev_outputis needed in the function signature if you want to use the value from the prior function's value. Obviously the prior function should have returned something for this to work- If there are errors with too many params being passed into a function node, add **kwargs to your function
- Args can be overriden at any time using the following (this merges the kwargs in the background with priority to the user):
add_two_nums_node.user_params = {
a : 10
}
Acknowledgements
Shoutout to:
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 dagent-0.0.6.tar.gz.
File metadata
- Download URL: dagent-0.0.6.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
489e99c475165508228a286c5fcf6264a69884fe25fe3f14d00b9d75c7153f34
|
|
| MD5 |
a9d5f737fa71865d618c342159fa505d
|
|
| BLAKE2b-256 |
65acb69d36fae1ddd7d68315a56de13c4be2a975cf8087556893433d948d90ae
|
File details
Details for the file dagent-0.0.6-py3-none-any.whl.
File metadata
- Download URL: dagent-0.0.6-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0993577c8b31dd1e10dce5b43504e7900bd6501d3541cac7269c03fc648073a8
|
|
| MD5 |
27ea64dffaf4d84d6a865956d0dcc88e
|
|
| BLAKE2b-256 |
ddbfe7a7263281979644c0cef5b85196a970f9a6ba7eab8b18ad61f569c8d29a
|