Table of Contents

Class ReasoningStep<T>

Namespace
AiDotNet.Reasoning.Models
Assembly
AiDotNet.dll

Represents a single step in a reasoning chain, capturing the thought process and evaluation.

public class ReasoningStep<T>

Type Parameters

T

The numeric type used for scoring and calculations (e.g., double, float).

Inheritance
ReasoningStep<T>
Inherited Members

Remarks

For Beginners: Think of a reasoning step like a single line in showing your work on a math problem. When you solve "What is 15% of 240?", your steps might be: - Step 1: "Convert 15% to decimal: 15/100 = 0.15" - Step 2: "Multiply by 240: 0.15 × 240 = 36" - Step 3: "Therefore, the answer is 36"

Each ReasoningStep captures:

  • What you thought (the reasoning text)
  • How confident you are (the score)
  • Whether this step was verified/checked
  • Any feedback or corrections made

Example Usage:

var step1 = new ReasoningStep<double>
{
    StepNumber = 1,
    Content = "Convert 15% to decimal: 15/100 = 0.15",
    Score = 1.0,  // High confidence - this is a straightforward conversion
    IsVerified = true
};

var step2 = new ReasoningStep<double>
{
    StepNumber = 2,
    Content = "Multiply by 240: 0.15 × 240 = 36",
    Score = 0.95,
    IsVerified = true,
    ExternalVerificationResult = "Calculator confirms: 0.15 * 240 = 36"
};

Constructors

ReasoningStep()

Initializes a new instance of the ReasoningStep<T> class.

public ReasoningStep()

Properties

Content

The actual reasoning content or thought for this step.

public string Content { get; set; }

Property Value

string

Remarks

For Beginners: This is what you're actually thinking or doing in this step. It should be clear and specific, like "Calculate the area by multiplying length × width" rather than vague like "Do the math."

CreatedAt

Timestamp when this step was created.

public DateTime CreatedAt { get; set; }

Property Value

DateTime

Remarks

For Beginners: Records when this reasoning step happened. Useful for: - Performance analysis (how long did reasoning take?) - Debugging (what order did things happen?) - Audit trails (when was this decision made?)

CriticFeedback

Feedback from critic model if verification was performed.

public string? CriticFeedback { get; set; }

Property Value

string

Remarks

For Beginners: This is like comments from a teacher reviewing your work. It might say things like: - "Good! The logic is sound and well-explained." - "This step needs more justification." - "Error: 15% should be 0.15, not 1.5"

ExternalVerificationResult

Result from external verification tool if applicable.

public string? ExternalVerificationResult { get; set; }

Property Value

string

Remarks

For Beginners: This stores the output from external verification tools. For example, if a calculator was used, this might contain "36" or "Calculation correct: 36".

IsVerified

Whether this step has been verified by a critic model or external tool.

public bool IsVerified { get; set; }

Property Value

bool

Remarks

For Beginners: This is like having someone check your work. If true, this step has been reviewed and confirmed to be correct. If false, it hasn't been checked yet.

Metadata

Additional metadata or context specific to this step.

public Dictionary<string, object> Metadata { get; set; }

Property Value

Dictionary<string, object>

Remarks

For Beginners: This is a flexible container for any extra information about this step that doesn't fit in the other properties. You can store things like: - Which sub-problem this step addresses - References to external sources - Alternative approaches considered

OriginalContent

Original content before any refinement (if the step was refined).

public string? OriginalContent { get; set; }

Property Value

string

Remarks

For Beginners: If you made a mistake and corrected it, this stores your original wrong answer so you can see what was changed. It's like keeping track of your eraser marks.

RefinementCount

Number of times this step was refined/corrected.

public int RefinementCount { get; set; }

Property Value

int

Remarks

For Beginners: This counts how many times you had to revise this step to get it right. It's like counting how many erasers you used on one problem: - 0 = Got it right the first time - 1 = Had to fix it once - 3 = Took three attempts to get it right

Score

Confidence or quality score for this step (typically 0.0 to 1.0).

public T Score { get; set; }

Property Value

T

Remarks

For Beginners: This is how confident the AI is that this step is correct. Think of it as a percentage: - 1.0 = 100% confident (absolutely certain) - 0.8 = 80% confident (pretty sure) - 0.5 = 50% confident (unsure, might be wrong) - 0.0 = 0% confident (probably incorrect)

Higher scores mean the step is more trustworthy.

StepNumber

The sequential number of this step in the reasoning chain (starting from 1).

public int StepNumber { get; set; }

Property Value

int

Remarks

For Beginners: This is like the step number when showing your work: Step 1, Step 2, Step 3, etc. It helps keep track of the order of reasoning.

VerificationMethod

Tool or method used to verify this step externally (e.g., "Calculator", "CodeExecution").

public string? VerificationMethod { get; set; }

Property Value

string

Remarks

For Beginners: If external tools were used to check this step, this records which tool. For example: - "Calculator" - Mathematical calculation was verified - "PythonInterpreter" - Code execution was tested - "WolframAlpha" - Complex math was double-checked

Methods

ToString()

Returns a string representation of this reasoning step.

public override string ToString()

Returns

string

A formatted string showing the step number and content.

Remarks

For Beginners: This creates a human-readable version of the step, useful for logging or debugging.