Skip to content

Commit fd908ed

Browse files
Add more tests
1 parent eb33b31 commit fd908ed

File tree

4 files changed

+692
-101
lines changed

4 files changed

+692
-101
lines changed

src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/IntentResolutionRating.cs

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,43 @@ namespace Microsoft.Extensions.AI.Evaluation.Quality;
1111

1212
internal sealed class IntentResolutionRating
1313
{
14-
public static IntentResolutionRating Inconclusive { get; } = new IntentResolutionRating();
14+
public static IntentResolutionRating Inconclusive { get; } =
15+
new IntentResolutionRating(
16+
resolutionScore: 0,
17+
explanation: string.Empty,
18+
agentPerceivedIntent: string.Empty,
19+
actualUserIntent: string.Empty,
20+
conversationHasIntent: false,
21+
correctIntentDetected: false,
22+
intentResolved: false);
1523

24+
[JsonRequired]
1625
[JsonPropertyName("resolution_score")]
17-
public int ResolutionScore { get; }
26+
public int ResolutionScore { get; set; }
1827

28+
[JsonRequired]
1929
[JsonPropertyName("explanation")]
20-
public string? Explanation { get; }
30+
public string Explanation { get; set; }
2131

32+
[JsonRequired]
2233
[JsonPropertyName("agent_perceived_intent")]
23-
public string? AgentPerceivedIntent { get; }
34+
public string AgentPerceivedIntent { get; set; }
2435

36+
[JsonRequired]
2537
[JsonPropertyName("actual_user_intent")]
26-
public string? ActualUserIntent { get; }
38+
public string ActualUserIntent { get; set; }
2739

40+
[JsonRequired]
2841
[JsonPropertyName("conversation_has_intent")]
29-
public bool ConversationHasIntent { get; }
42+
public bool ConversationHasIntent { get; set; }
3043

44+
[JsonRequired]
3145
[JsonPropertyName("correct_intent_detected")]
32-
public bool CorrectIntentDetected { get; }
46+
public bool CorrectIntentDetected { get; set; }
3347

48+
[JsonRequired]
3449
[JsonPropertyName("intent_resolved")]
35-
public bool IntentResolved { get; }
50+
public bool IntentResolved { get; set; }
3651

3752
private const int MinValue = 1;
3853
private const int MaxValue = 5;
@@ -42,13 +57,13 @@ internal sealed class IntentResolutionRating
4257
[JsonConstructor]
4358
#pragma warning disable S107 // Methods should not have too many parameters
4459
public IntentResolutionRating(
45-
int resolutionScore = -1,
46-
string? explanation = null,
47-
string? agentPerceivedIntent = null,
48-
string? actualUserIntent = null,
49-
bool conversationHasIntent = false,
50-
bool correctIntentDetected = false,
51-
bool intentResolved = false)
60+
int resolutionScore,
61+
string explanation,
62+
string agentPerceivedIntent,
63+
string actualUserIntent,
64+
bool conversationHasIntent,
65+
bool correctIntentDetected,
66+
bool intentResolved)
5267
#pragma warning restore S107
5368
{
5469
ResolutionScore = resolutionScore;

src/Libraries/Microsoft.Extensions.AI.Evaluation.Quality/RelevanceTruthAndCompletenessRating.cs

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,44 @@ namespace Microsoft.Extensions.AI.Evaluation.Quality;
1111

1212
internal sealed class RelevanceTruthAndCompletenessRating
1313
{
14-
public static RelevanceTruthAndCompletenessRating Inconclusive { get; }
15-
= new RelevanceTruthAndCompletenessRating(relevance: -1, truth: -1, completeness: -1);
14+
public static RelevanceTruthAndCompletenessRating Inconclusive { get; } =
15+
new RelevanceTruthAndCompletenessRating(
16+
relevance: 0,
17+
relevanceReasoning: string.Empty,
18+
relevanceReasons: [],
19+
truth: 0,
20+
truthReasoning: string.Empty,
21+
truthReasons: [],
22+
completeness: 0,
23+
completenessReasoning: string.Empty,
24+
completenessReasons: []);
1625

17-
public int Relevance { get; }
18-
public string? RelevanceReasoning { get; }
19-
public string[] RelevanceReasons { get; } = [];
26+
[JsonRequired]
27+
public int Relevance { get; set; }
2028

21-
public int Truth { get; }
22-
public string? TruthReasoning { get; }
23-
public string[] TruthReasons { get; } = [];
29+
[JsonRequired]
30+
public string RelevanceReasoning { get; set; }
2431

25-
public int Completeness { get; }
26-
public string? CompletenessReasoning { get; }
27-
public string[] CompletenessReasons { get; } = [];
32+
[JsonRequired]
33+
public string[] RelevanceReasons { get; set; }
34+
35+
[JsonRequired]
36+
public int Truth { get; set; }
37+
38+
[JsonRequired]
39+
public string TruthReasoning { get; set; }
40+
41+
[JsonRequired]
42+
public string[] TruthReasons { get; set; }
43+
44+
[JsonRequired]
45+
public int Completeness { get; set; }
46+
47+
[JsonRequired]
48+
public string CompletenessReasoning { get; set; }
49+
50+
[JsonRequired]
51+
public string[] CompletenessReasons { get; set; }
2852

2953
private const int MinValue = 1;
3054
private const int MaxValue = 5;
@@ -36,17 +60,12 @@ internal sealed class RelevanceTruthAndCompletenessRating
3660
Completeness < MinValue || Completeness > MaxValue;
3761
#pragma warning restore S1067
3862

39-
public RelevanceTruthAndCompletenessRating(int relevance, int truth, int completeness)
40-
{
41-
(Relevance, Truth, Completeness) = (relevance, truth, completeness);
42-
}
43-
4463
[JsonConstructor]
4564
#pragma warning disable S107 // Methods should not have too many parameters.
4665
public RelevanceTruthAndCompletenessRating(
47-
int relevance, string? relevanceReasoning, string[] relevanceReasons,
48-
int truth, string? truthReasoning, string[] truthReasons,
49-
int completeness, string? completenessReasoning, string[] completenessReasons)
66+
int relevance, string relevanceReasoning, string[] relevanceReasons,
67+
int truth, string truthReasoning, string[] truthReasons,
68+
int completeness, string completenessReasoning, string[] completenessReasons)
5069
#pragma warning restore S107
5170
{
5271
(Relevance, RelevanceReasoning, RelevanceReasons,

0 commit comments

Comments
 (0)