IEvaluator.EvaluateAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Evaluates the supplied modelResponse
and returns an EvaluationResult
containing one or more EvaluationMetrics.
public System.Threading.Tasks.ValueTask<Microsoft.Extensions.AI.Evaluation.EvaluationResult> EvaluateAsync (System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, Microsoft.Extensions.AI.ChatMessage modelResponse, Microsoft.Extensions.AI.Evaluation.ChatConfiguration? chatConfiguration = default, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.Evaluation.EvaluationContext>? additionalContext = default, System.Threading.CancellationToken cancellationToken = default);
abstract member EvaluateAsync : seq<Microsoft.Extensions.AI.ChatMessage> * Microsoft.Extensions.AI.ChatMessage * Microsoft.Extensions.AI.Evaluation.ChatConfiguration * seq<Microsoft.Extensions.AI.Evaluation.EvaluationContext> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.Extensions.AI.Evaluation.EvaluationResult>
Public Function EvaluateAsync (messages As IEnumerable(Of ChatMessage), modelResponse As ChatMessage, Optional chatConfiguration As ChatConfiguration = Nothing, Optional additionalContext As IEnumerable(Of EvaluationContext) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of EvaluationResult)
Parameters
- messages
- IEnumerable<ChatMessage>
The conversation history including the request that produced the supplied modelResponse
.
- modelResponse
- ChatMessage
The response that is to be evaluated.
- chatConfiguration
- ChatConfiguration
A ChatConfiguration that specifies the IChatClient and the IEvaluationTokenCounter that should be used if the evaluation is performed using an AI model.
- additionalContext
- IEnumerable<EvaluationContext>
Additional contextual information (beyond that which is available in messages
) that the
IEvaluator may need to accurately evaluate the supplied modelResponse
.
- cancellationToken
- CancellationToken
A CancellationToken that can cancel the evaluation operation.
Returns
An EvaluationResult containing one or more EvaluationMetrics.
Remarks
The Names of the EvaluationMetrics contained in the returned EvaluationResult should match EvaluationMetricNames.
Also note that chatConfiguration
must not be omitted if the evaluation is performed using an AI model.