@@ -153,17 +153,33 @@ At its furthest point (conjunction), Mars is about 250 million miles from Earth.
153153 The distance varies due to the elliptical orbits of both planets.
154154 """ ;
155155
156- IEnumerable < EvaluationContext > additionalContext =
157- [
158- new GroundednessProEvaluatorContext ( groundingContext ) ,
159- new UngroundedAttributesEvaluatorContext ( groundingContext )
160- ] ;
156+ GroundednessProEvaluatorContext groundednessProContext = new GroundednessProEvaluatorContext ( groundingContext ) ;
157+ UngroundedAttributesEvaluatorContext ungroundedAttributesContext = new UngroundedAttributesEvaluatorContext ( groundingContext ) ;
158+ IEnumerable < EvaluationContext > additionalContext = [ groundednessProContext , ungroundedAttributesContext ] ;
161159
162160 EvaluationResult result = await scenarioRun . EvaluateAsync ( messages , response , additionalContext ) ;
163161
164162 Assert . False (
165163 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
166164 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
165+
166+ Assert . Equal ( 6 , result . Metrics . Count ) ;
167+ Assert . True ( result . TryGet ( SelfHarmEvaluator . SelfHarmMetricName , out NumericMetric ? _ ) ) ;
168+ Assert . True ( result . TryGet ( SexualEvaluator . SexualMetricName , out NumericMetric ? _ ) ) ;
169+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedMaterialMetricName , out BooleanMetric ? _ ) ) ;
170+ Assert . True ( result . TryGet ( GroundednessProEvaluator . GroundednessProMetricName , out NumericMetric ? groundednessPro ) ) ;
171+ Assert . True ( result . TryGet ( UngroundedAttributesEvaluator . UngroundedAttributesMetricName , out BooleanMetric ? ungroundedAttributes ) ) ;
172+ Assert . True ( result . TryGet ( IndirectAttackEvaluator . IndirectAttackMetricName , out BooleanMetric ? _ ) ) ;
173+
174+ Assert . True (
175+ groundednessPro . Context ? . Count is 1 &&
176+ groundednessPro . Context . TryGetValue ( GroundednessProEvaluatorContext . GroundingContextName , out EvaluationContext ? context1 ) &&
177+ ReferenceEquals ( context1 , groundednessProContext ) ) ;
178+
179+ Assert . True (
180+ ungroundedAttributes . Context ? . Count is 1 &&
181+ ungroundedAttributes . Context . TryGetValue ( UngroundedAttributesEvaluatorContext . GroundingContextName , out EvaluationContext ? context2 ) &&
182+ ReferenceEquals ( context2 , ungroundedAttributesContext ) ) ;
167183 }
168184
169185 [ ConditionalFact ]
@@ -212,17 +228,33 @@ At its closest (opposition), Jupiter is about 365 million miles away.
212228 At its furthest (conjunction), it can be approximately 601 million miles away.
213229 """ ;
214230
215- IEnumerable < EvaluationContext > additionalContext =
216- [
217- new GroundednessProEvaluatorContext ( groundingContext ) ,
218- new UngroundedAttributesEvaluatorContext ( groundingContext )
219- ] ;
231+ GroundednessProEvaluatorContext groundednessProContext = new GroundednessProEvaluatorContext ( groundingContext ) ;
232+ UngroundedAttributesEvaluatorContext ungroundedAttributesContext = new UngroundedAttributesEvaluatorContext ( groundingContext ) ;
233+ IEnumerable < EvaluationContext > additionalContext = [ groundednessProContext , ungroundedAttributesContext ] ;
220234
221235 EvaluationResult result = await scenarioRun . EvaluateAsync ( messages , response2 , additionalContext ) ;
222236
223237 Assert . False (
224238 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
225239 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
240+
241+ Assert . Equal ( 6 , result . Metrics . Count ) ;
242+ Assert . True ( result . TryGet ( SelfHarmEvaluator . SelfHarmMetricName , out NumericMetric ? _ ) ) ;
243+ Assert . True ( result . TryGet ( SexualEvaluator . SexualMetricName , out NumericMetric ? _ ) ) ;
244+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedMaterialMetricName , out BooleanMetric ? _ ) ) ;
245+ Assert . True ( result . TryGet ( GroundednessProEvaluator . GroundednessProMetricName , out NumericMetric ? groundednessPro ) ) ;
246+ Assert . True ( result . TryGet ( UngroundedAttributesEvaluator . UngroundedAttributesMetricName , out BooleanMetric ? ungroundedAttributes ) ) ;
247+ Assert . True ( result . TryGet ( IndirectAttackEvaluator . IndirectAttackMetricName , out BooleanMetric ? _ ) ) ;
248+
249+ Assert . True (
250+ groundednessPro . Context ? . Count is 1 &&
251+ groundednessPro . Context . TryGetValue ( GroundednessProEvaluatorContext . GroundingContextName , out EvaluationContext ? context1 ) &&
252+ ReferenceEquals ( context1 , groundednessProContext ) ) ;
253+
254+ Assert . True (
255+ ungroundedAttributes . Context ? . Count is 1 &&
256+ ungroundedAttributes . Context . TryGetValue ( UngroundedAttributesEvaluatorContext . GroundingContextName , out EvaluationContext ? context2 ) &&
257+ ReferenceEquals ( context2 , ungroundedAttributesContext ) ) ;
226258 }
227259
228260 [ ConditionalFact ]
@@ -250,6 +282,15 @@ await _imageContentSafetyReportingConfiguration.CreateScenarioRunAsync(
250282 Assert . False (
251283 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
252284 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
285+
286+ Assert . Equal ( 7 , result . Metrics . Count ) ;
287+ Assert . True ( result . TryGet ( HateAndUnfairnessEvaluator . HateAndUnfairnessMetricName , out NumericMetric ? _ ) ) ;
288+ Assert . True ( result . TryGet ( ViolenceEvaluator . ViolenceMetricName , out NumericMetric ? _ ) ) ;
289+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedMaterialMetricName , out BooleanMetric ? _ ) ) ;
290+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedArtworkMetricName , out BooleanMetric ? _ ) ) ;
291+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedFictionalCharactersMetricName , out BooleanMetric ? _ ) ) ;
292+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedLogosAndBrandsMetricName , out BooleanMetric ? _ ) ) ;
293+ Assert . True ( result . TryGet ( IndirectAttackEvaluator . IndirectAttackMetricName , out BooleanMetric ? _ ) ) ;
253294 }
254295
255296 [ ConditionalFact ]
@@ -277,6 +318,15 @@ await _imageContentSafetyReportingConfiguration.CreateScenarioRunAsync(
277318 Assert . False (
278319 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
279320 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
321+
322+ Assert . Equal ( 7 , result . Metrics . Count ) ;
323+ Assert . True ( result . TryGet ( HateAndUnfairnessEvaluator . HateAndUnfairnessMetricName , out NumericMetric ? _ ) ) ;
324+ Assert . True ( result . TryGet ( ViolenceEvaluator . ViolenceMetricName , out NumericMetric ? _ ) ) ;
325+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedMaterialMetricName , out BooleanMetric ? _ ) ) ;
326+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedArtworkMetricName , out BooleanMetric ? _ ) ) ;
327+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedFictionalCharactersMetricName , out BooleanMetric ? _ ) ) ;
328+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedLogosAndBrandsMetricName , out BooleanMetric ? _ ) ) ;
329+ Assert . True ( result . TryGet ( IndirectAttackEvaluator . IndirectAttackMetricName , out BooleanMetric ? _ ) ) ;
280330 }
281331
282332 [ ConditionalFact ]
@@ -317,6 +367,15 @@ await _imageContentSafetyReportingConfiguration.CreateScenarioRunAsync(
317367 Assert . False (
318368 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
319369 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
370+
371+ Assert . Equal ( 7 , result . Metrics . Count ) ;
372+ Assert . True ( result . TryGet ( HateAndUnfairnessEvaluator . HateAndUnfairnessMetricName , out NumericMetric ? _ ) ) ;
373+ Assert . True ( result . TryGet ( ViolenceEvaluator . ViolenceMetricName , out NumericMetric ? _ ) ) ;
374+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedMaterialMetricName , out BooleanMetric ? _ ) ) ;
375+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedArtworkMetricName , out BooleanMetric ? _ ) ) ;
376+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedFictionalCharactersMetricName , out BooleanMetric ? _ ) ) ;
377+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedLogosAndBrandsMetricName , out BooleanMetric ? _ ) ) ;
378+ Assert . True ( result . TryGet ( IndirectAttackEvaluator . IndirectAttackMetricName , out BooleanMetric ? _ ) ) ;
320379 }
321380
322381 [ ConditionalFact ]
@@ -370,6 +429,15 @@ These distances are approximate and can vary slightly depending on the specific
370429 Assert . False (
371430 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
372431 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
432+
433+ Assert . Equal ( 7 , result . Metrics . Count ) ;
434+ Assert . True ( result . TryGet ( HateAndUnfairnessEvaluator . HateAndUnfairnessMetricName , out NumericMetric ? _ ) ) ;
435+ Assert . True ( result . TryGet ( ViolenceEvaluator . ViolenceMetricName , out NumericMetric ? _ ) ) ;
436+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedMaterialMetricName , out BooleanMetric ? _ ) ) ;
437+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedArtworkMetricName , out BooleanMetric ? _ ) ) ;
438+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedFictionalCharactersMetricName , out BooleanMetric ? _ ) ) ;
439+ Assert . True ( result . TryGet ( ProtectedMaterialEvaluator . ProtectedLogosAndBrandsMetricName , out BooleanMetric ? _ ) ) ;
440+ Assert . True ( result . TryGet ( IndirectAttackEvaluator . IndirectAttackMetricName , out BooleanMetric ? _ ) ) ;
373441 }
374442
375443 [ ConditionalFact ]
@@ -396,6 +464,9 @@ await _codeVulnerabilityReportingConfiguration.CreateScenarioRunAsync(
396464 Assert . False (
397465 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
398466 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
467+
468+ Assert . Single ( result . Metrics ) ;
469+ Assert . True ( result . TryGet ( CodeVulnerabilityEvaluator . CodeVulnerabilityMetricName , out BooleanMetric ? _ ) ) ;
399470 }
400471
401472 [ ConditionalFact ]
@@ -434,6 +505,9 @@ await _codeVulnerabilityReportingConfiguration.CreateScenarioRunAsync(
434505 Assert . False (
435506 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
436507 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
508+
509+ Assert . Single ( result . Metrics ) ;
510+ Assert . True ( result . TryGet ( CodeVulnerabilityEvaluator . CodeVulnerabilityMetricName , out BooleanMetric ? _ ) ) ;
437511 }
438512
439513 [ ConditionalFact ]
@@ -465,6 +539,13 @@ await _mixedQualityAndSafetyReportingConfiguration.CreateScenarioRunAsync(
465539 Assert . False (
466540 result . ContainsDiagnostics ( d => d . Severity is EvaluationDiagnosticSeverity . Error ) ,
467541 string . Join ( "\r \n \r \n " , result . Metrics . Values . SelectMany ( m => m . Diagnostics ?? [ ] ) . Select ( d => d . ToString ( ) ) ) ) ;
542+
543+ Assert . Equal ( 5 , result . Metrics . Count ) ;
544+ Assert . True ( result . TryGet ( FluencyEvaluator . FluencyMetricName , out NumericMetric ? _ ) ) ;
545+ Assert . True ( result . TryGet ( HateAndUnfairnessEvaluator . HateAndUnfairnessMetricName , out NumericMetric ? _ ) ) ;
546+ Assert . True ( result . TryGet ( SelfHarmEvaluator . SelfHarmMetricName , out NumericMetric ? _ ) ) ;
547+ Assert . True ( result . TryGet ( SexualEvaluator . SexualMetricName , out NumericMetric ? _ ) ) ;
548+ Assert . True ( result . TryGet ( ViolenceEvaluator . ViolenceMetricName , out NumericMetric ? _ ) ) ;
468549 }
469550
470551 [ MemberNotNull ( nameof ( _contentSafetyReportingConfiguration ) ) ]
0 commit comments