- Notifications
You must be signed in to change notification settings - Fork845
[AI Evaluation] Add versioning to reporting and caching#6070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
10 commits Select commitHold shift + click to select a range
1d038cd [AI Evaluation] Add versioning to reporting and caching
peterwaldf3bbe08 Move CacheVersion key down into the DistributedCachingChatClient
peterwald3a06929 Update src/Libraries/Microsoft.Extensions.AI/ChatCompletion/Distribut…
stephentoubf332da2 Update src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSh…
peterwald0883cc0 Update src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSh…
peterwald3923045 Rollback formatVersion init change
peterwald7739a01 Merge branch 'main' into pewaldsc/versioning
peterwald4e74bf3 Make version const internal, update comments.
peterwald61617ff Add assertion for report version
peterwald30fb676 Make ReportVersion property readonly
peterwaldFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletionssrc/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/Defaults.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletionsrc/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/CSharp/ScenarioRunResult.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 7 additions & 2 deletionssrc/Libraries/Microsoft.Extensions.AI/ChatCompletion/DistributedCachingChatClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -107,6 +107,11 @@ protected override async Task WriteCacheStreamingAsync(string key, IReadOnlyList | ||
| /// The generated cache key is not guaranteed to be stable across releases of the library. | ||
| /// </para> | ||
| /// </remarks> | ||
| protected override string GetCacheKey(params ReadOnlySpan<object?> values) | ||
| { | ||
| // Bump the cache version to invalidate existing caches if the serialization format changes in a breaking way. | ||
| const int CacheVersion = 1; | ||
peterwald marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| return AIJsonUtilities.HashDataToString([CacheVersion, .. values], _jsonSerializerOptions); | ||
peterwald marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| } | ||
| } | ||
2 changes: 2 additions & 0 deletionstest/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting.Tests/ScenarioRunResultTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -38,6 +38,7 @@ public void SerializeScenarioRunResult() | ||
| messages: [new ChatMessage(ChatRole.User, "prompt")], | ||
| modelResponse: new ChatResponse(new ChatMessage(ChatRole.Assistant, "response")), | ||
| evaluationResult: new EvaluationResult(booleanMetric, numericMetric, stringMetric, metricWithNoValue)); | ||
| Assert.Equal(Defaults.ReportingFormatVersion, entry.FormatVersion); | ||
peterwald marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| string json = JsonSerializer.Serialize(entry, SerializerContext.Default.ScenarioRunResult); | ||
| ScenarioRunResult? deserialized = JsonSerializer.Deserialize<ScenarioRunResult>(json, SerializerContext.Default.ScenarioRunResult); | ||
| @@ -49,6 +50,7 @@ public void SerializeScenarioRunResult() | ||
| Assert.Equal(entry.CreationTime, deserialized.CreationTime); | ||
| Assert.True(entry.Messages.SequenceEqual(deserialized.Messages, ChatMessageComparer.Instance)); | ||
| Assert.Equal(entry.ModelResponse, deserialized.ModelResponse, ChatResponseComparer.Instance); | ||
| Assert.Equal(entry.FormatVersion, deserialized.FormatVersion); | ||
| ValidateEquivalence(entry.EvaluationResult, deserialized.EvaluationResult); | ||
| } | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.