ToolAugmentedReasoningRetriever<T>

Models & Types · AiDotNet.RetrievalAugmentedGeneration.AdvancedPatterns

Tool-augmented reasoning retriever that can use external tools during reasoning.

For Beginners

Think of this like a researcher with access to specialized equipment.

Without tools:

  • “What is the compound annual growth rate of solar installations from 2015 to 2023?”
  • Can only retrieve documents about growth rates

With tools:

  • Retrieves data: 2015: 50 GW, 2023: 400 GW
  • Recognizes calculation needed
  • Uses calculator tool: CAGR = (400/50)^(1/8) - 1 = 29.4%
  • Incorporates calculation into answer

Supported tool types:

  • Calculator: Mathematical computations
  • Code: Execute code for data processing
  • Custom: User-defined tools

How It Works

This pattern extends multi-step reasoning by incorporating external tools such as calculators, code interpreters, or specialized APIs. The system can recognize when a tool is needed, invoke it, and incorporate the results into the reasoning process.

Constructors

Constructor Summary
ToolAugmentedReasoningRetriever(IGenerator<T> generator, RetrieverBase<T> baseRetriever) Initializes a new instance of the ToolAugmentedReasoningRetriever class.

Methods

Method Summary
ToolAugmentedResult<T> RetrieveWithTools(string query, int topK, Dictionary<string, object> metadataFilters) Retrieves documents using tool-augmented reasoning.
void RegisterTool(string toolName, Func<string, string> toolFunction) Registers a custom tool for use during reasoning.