ReasoningChain<T>

Models & Types · AiDotNet.Reasoning.Models

Represents a complete chain of reasoning steps from problem to solution.

For Beginners

A reasoning chain is like showing your complete work on a problem, from start to finish. Just like in math class where you write out all your steps:

Problem: “What is 15% of 240?” Step 1: Convert percentage to decimal Step 2: Multiply Step 3: State the answer

The ReasoningChain class keeps track of all these steps together, along with scores that tell you how confident the AI is about each step. It uses a Vector to store scores efficiently, which is important for machine learning operations.

How It Works

Example Usage:

Constructors

Constructor Summary
ReasoningChain() Initializes a new instance of the ReasoningChain class.

Properties

Property Summary
DateTime StartedAt { get; set; } When this reasoning chain was started.
DateTime? CompletedAt { get; set; } When this reasoning chain was completed.
Dictionary<string, object> Metadata { get; set; } Additional metadata or context for this reasoning chain.
List<ReasoningStep<T>> Steps { get; set; } The ordered list of reasoning steps in this chain.
T OverallScore { get; set; } Overall confidence score for the entire reasoning chain.
TimeSpan Duration { get; } Total time spent on this reasoning chain.
Vector<T> StepScores { get; } Vector of confidence scores for each step, enabling efficient ML operations.
bool IsFullyVerified { get; } Whether every step in this chain has been verified.
int TotalRefinements { get; } Total number of refinements made across all steps in this chain.
string FinalAnswer { get; set; } The final answer or conclusion from this reasoning chain.
string Query { get; set; } The original query or problem that this reasoning chain addresses.

Methods

Method Summary
T GetAverageScore() Gets the average confidence score across all steps.
T GetMinimumScore() Gets the minimum confidence score across all steps.
string ToString() Returns a formatted string representation of the entire reasoning chain.
void AddStep(ReasoningStep<T> step) Adds a reasoning step to this chain.