Tutorial Overview
The next step in our tutorial is connecting ourNodes together to build a DAG.
Building a DAG
All we need to do is instantiate an instance of a DAG, add instances of ourNodes, and add edges between them.
Instantiate the DAG
First, we need to import theDAG class.
example_dag.py
DAG.
example_dag.py
DAG takes no arguments. We’ll set everything up through function calls to it.
Import our cat fact tool
We need to import ourCatFactsAPITool class from the previous tutorial.
example_dag.py
Add Nodes
Next, we’ll add ourNodes using the add_node function.
example_dag.py
Add Edges
Finally, we’ll add edges between ourNodes using the add_edge function.
example_dag.py
distinguish_cat_fact_llm edge is easy, because we already changed the output name of cat_fact_tool to cat_fact.
example_dag.py
cat_fact_2.
Every edge in Trellis allows you to optionally transform data between nodes when you add an edge. We designed it this way to reduce the amount
of code you’d have to rewrite.
Putting it all together
That’s it! We’ve put ourDAG together. In the next and final tutorial, we’ll run it. Visit the DAG reference to learn more. Here’s the full code for this tutorial.
example_dag.py

