SuperAPI AI Directory

DAGent

DAGent is a Python library with a clear design orientation, used to quickly build AI agents through a directed acyclic graph (DAG) structure, without additional overhead. Its core idea is to set existing Python functions as nodes in the graph, and have a large language model infer which function should be executed through "decision nodes," thereby implementing agent behavior. Tools are just ordinary functions, and the LLM can call them as tools. The library supports installation (pip install dagent or rye add dagent), and requires the system to provide the required API key, using OPENAI_API_KEY by default. DAGent supports using different LLM models for reasoning and tool description generation, and the model can be specified through call_llm, call_llm_tool, or when compiling a DecisionNode, for example groq/llama3-70b-8192. In use, it is recommended to write docstrings and type annotations for functions to help the LLM understand. The .compile() method automatically generates and saves tool descriptions to the Tool_JSON folder, which can be manually edited to improve reliability. If data is passed between functions, the prev_output parameter must be included in the function signature; if there is a problem with extra parameters, **kwargs can be added. Parameters can be overridden by the user at runtime. This library is suitable for developers who want to quickly build agent workflows by reusing existing Python code.

Open website

About this tool

DAGent is a Python library with a clear design orientation, intended to help developers quickly build AI agents using existing Python code and avoid unnecessary complexity. Its core is to structure AI agents as workflows: each Python function is set as a node in the graph, and agent behavior is implemented by having a large language model (LLM) infer which function should be run, a process completed by an abstract "Decision Node." Under this design, tools are just ordinary functions that the LLM can use.

Installation and configuration: It can be installed via pip install dagent or rye add dagent. When using it, make sure the selected API key is provided in the system, using OPENAI_API_KEY by default. For a quick start example, see dagent/examples/quickstart_simple_agent.py.

Main capabilities and usage:

  1. Function nodes: used to run Python functions, and can be attached to a DecisionNode to be treated as tools, allowing the LLM to choose which function to run.
  2. Decision nodes: here the LLM chooses the function to run from the given options. Its .compile() method automatically generates and saves tool descriptions to the Tool_JSON folder. If errors occur or tool options change, the parameter force_load=True can be used to force loading. Developers can freely edit the generated function/tool descriptions to improve agent reliability.
  3. prev_output parameter: if data needs to be passed between functions, this parameter must be included in the function signature; the previous function should return the corresponding value for it to take effect.
  4. Exception handling: if extra parameters are passed in or abnormal situations occur, **kwargs can be added to the function to see whether there are hidden parameters that need to be handled.
  5. Parameter overriding: parameters can be overridden at any time. The override operation merges kwargs in the background, and user-provided parameters take precedence.

Using different models: DAGent supports using different LLM models for reasoning and tool description generation. The model can be specified when calling call_llm or call_llm_tool, or when compiling a DecisionNode. For example, use the groq/llama3-70b-8192 model.

Applicable scenarios and limitations: DAGent is suitable for people who want to reuse existing Python code, organize workflows in a graph structure, and quickly create AI agents. It is recommended to write docstrings and type annotations for functions, especially in larger functions/tools, to help the LLM infer their functionality. Tool descriptions can be manually edited to improve reliability. Regarding the specific range of supported models, billing, performance, and other more information, the materials do not currently provide it.