Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma warning disable CA2016 // Forward the 'CancellationToken' parameter to methods that take it.
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor.

using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -24,6 +25,11 @@ static NLPEvaluatorTests()
{
if (Settings.Current.Configured)
{
string version = $"Product Version: {Constants.Version}";
string date = $"Date: {DateTime.UtcNow:dddd, dd MMMM yyyy}";
string projectName = $"Project: Integration Tests";
string testClass = $"Test Class: {nameof(NLPEvaluatorTests)}";
Comment thread
peterwald marked this conversation as resolved.

IEvaluator bleuEvaluator = new BLEUEvaluator();
IEvaluator gleuEvaluator = new GLEUEvaluator();
IEvaluator f1Evaluator = new F1Evaluator();
Expand All @@ -33,7 +39,7 @@ static NLPEvaluatorTests()
storageRootPath: Settings.Current.StorageRootPath,
evaluators: [bleuEvaluator, gleuEvaluator, f1Evaluator],
executionName: Constants.Version,
tags: []);
tags: [version, date, projectName, testClass]);
}
}

Expand All @@ -51,9 +57,7 @@ await _nlpReportingConfiguration.CreateScenarioRunAsync(
var gleuContext = new GLEUEvaluatorContext(referenceText);
var f1Context = new F1EvaluatorContext(referenceText);

var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, "The quick brown fox jumps over the lazy dog."));

EvaluationResult result = await scenarioRun.EvaluateAsync(response, [bleuContext, gleuContext, f1Context]);
EvaluationResult result = await scenarioRun.EvaluateAsync(referenceText, [bleuContext, gleuContext, f1Context]);

Assert.False(
result.ContainsDiagnostics(d => d.Severity >= EvaluationDiagnosticSeverity.Warning),
Expand All @@ -79,9 +83,7 @@ await _nlpReportingConfiguration.CreateScenarioRunAsync(
var gleuContext = new GLEUEvaluatorContext(referenceText);
var f1Context = new F1EvaluatorContext(referenceText);

var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, "What is the meaning of life?"));

EvaluationResult result = await scenarioRun.EvaluateAsync(response, [bleuContext, gleuContext, f1Context]);
EvaluationResult result = await scenarioRun.EvaluateAsync("What is the meaning of life?", [bleuContext, gleuContext, f1Context]);

Assert.False(
result.ContainsDiagnostics(d => d.Severity >= EvaluationDiagnosticSeverity.Warning),
Expand All @@ -102,9 +104,7 @@ public async Task AdditionalContextIsNotPassed()
await _nlpReportingConfiguration.CreateScenarioRunAsync(
scenarioName: $"Microsoft.Extensions.AI.Evaluation.Integration.Tests.{nameof(NLPEvaluatorTests)}.{nameof(AdditionalContextIsNotPassed)}");

var response = new ChatResponse(new ChatMessage(ChatRole.Assistant, "What is the meaning of life?"));

EvaluationResult result = await scenarioRun.EvaluateAsync(response);
EvaluationResult result = await scenarioRun.EvaluateAsync("What is the meaning of life?");

Assert.True(
result.Metrics.Values.All(m => m.ContainsDiagnostics(d => d.Severity is EvaluationDiagnosticSeverity.Error)),
Expand Down
Loading