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:
- 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.
- 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.
- 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.
- 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.
- 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.