Skip to content

[AI Evaluation] How should MEAI.Eval be used with GetStreamingResponseAsync #6342

@BrennanConroy

Description

@BrennanConroy

The examples I've seen for using the Eval library all use IChatClient.GetResponseAsync which returns a ChatResponse. The IChatClient.GetStreamingResponseAsync method returns a ChatResponseUpdate. So in order to use the evaluation library I need to do:

StringBuilder builder = new();
await foreach (var msg in IChatClient.GetStreamingResponseAsync())
{
    builder.Append(msg.Text);
}
scenarioRun.EvaluateAsync(chatMessages, new ChatResponse(new ChatMessage(ChatRole.Assistant, builder.ToString())

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-ai-evalMicrosoft.Extensions.AI.Evaluation and related

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions