5. A RAG agent that does math
In our third iteration of the agent we've combined the two previous agents, so we've defined both sumNumbers
and a QueryEngineTool
and created an array of two tools. The tools support both Zod and JSON Schema for parameter definition:
You can also use JSON Schema to define the tool parameters as an alternative to Zod.
These tool descriptions are identical to the ones we previously defined. Now let's ask it 3 questions in a row:
We'll abbreviate the output, but here are the important things to spot:
This is the first tool call, where it used the query engine to get the public health budget.
In the second tool call, it got the police budget also from the query engine.
In the final tool call, it used the sumNumbers
function to add the two budgets together. Perfect! This leads to the final answer:
Great! Now let's improve accuracy by improving our parsing with LlamaParse.
Last updated on