EvaluationContext Class

Definition

An abstract base class that models additional contextual information (beyond that which is available in the conversation history) or other data that an IEvaluator may need to accurately evaluate supplied responses.

public ref class EvaluationContext abstract
public abstract class EvaluationContext
type EvaluationContext = class
Public MustInherit Class EvaluationContext
Inheritance
EvaluationContext
Derived

Remarks

EvaluationContext objects are intended to be simple data containers that contain the contextual information required for evaluation and little (if any) behavior.

An IEvaluator that needs additional contextual information can require that callers should include an instance of a specific derived EvaluationContext (containing the required contextual information) when they call EvaluateAsync(IEnumerable<ChatMessage>, ChatResponse, ChatConfiguration, IEnumerable<EvaluationContext>, CancellationToken).

Derived implementations of EvaluationContext are free to include any additional properties as needed. However, the expectation is that the Contents property will always return a collection of AIContents that represent all the contextual information that is modeled by the EvaluationContext.

This is because an IEvaluator can (optionally) choose to record any EvaluationContexts that it used, in the Context property of each EvaluationMetric that it produces. When EvaluationMetrics are serialized (for example, as part of the result storage and report generation functionality available in the Microsoft.Extensions.AI.Evaluation.Reporting NuGet package), the EvaluationContexts recorded within the Context will also be serialized. However, for each such EvaluationContext, only the information captured within Contents will be serialized. Any information that is (only) present in custom derived properties will not be serialized. Therefore, in order to ensure that the contextual information included as part of an EvaluationContext is stored and reported accurately, it is important to ensure that the Contents property returns a collection of AIContents that represent all the contextual information that is modeled by the EvaluationContext.

Constructors

EvaluationContext(String, AIContent[])

Initializes a new instance of the EvaluationContext class.

EvaluationContext(String, IEnumerable<AIContent>)

Initializes a new instance of the EvaluationContext class.

EvaluationContext(String, String)

Initializes a new instance of the EvaluationContext class.

Properties

Contents

Gets or sets a list of AIContent objects that include all the information present in this EvaluationContext.

Name

Gets or sets the name for this EvaluationContext.

Applies to