StringMetric class

An EvaluationMetric with a string value.

Commonly used to represent one value from an enumeration of possible categorical outcomes.

Inheritance
Available extensions
Annotations
  • @Source(name: 'StringMetric.cs', namespace: 'Microsoft.Extensions.AI.Evaluation', repository: 'dotnet/extensions', path: 'src/Libraries/Microsoft.Extensions.AI.Evaluation/')

Constructors

StringMetric(String name, {String? value, String? reason})
Creates a StringMetric with the given name, optional value, and optional reason.

Properties

context Map<String, EvaluationContext>?
Contexts considered by the evaluator when producing this metric.
getter/setter pairinherited
diagnostics List<EvaluationDiagnostic>?
Diagnostic messages associated with this metric.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
interpretation EvaluationMetricInterpretation?
Interpretation of whether this result is good or bad, passed or failed.
getter/setter pairinherited
metadata Map<String, String>?
Arbitrary string metadata associated with this metric.
getter/setter pairinherited
name String
The name of this metric.
getter/setter pairinherited
reason String?
Optional commentary on the metric result.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value String?
The string value of this metric.
getter/setter pair

Methods

addDiagnostic(EvaluationDiagnostic diagnostic) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds diagnostic to EvaluationMetric.diagnostics.
addDiagnostics(Iterable<EvaluationDiagnostic> newDiagnostics) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds all newDiagnostics to EvaluationMetric.diagnostics.
addOrUpdateChatMetadata(ChatResponse response, {Duration? duration}) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Records model ID and token counts from a ChatResponse as metadata.
addOrUpdateContext(EvaluationContext ctx) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds or replaces ctx in EvaluationMetric.context by name.
addOrUpdateContextAll(Iterable<EvaluationContext> contexts) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Adds or replaces multiple contexts by name.
addOrUpdateDurationMetadata(Duration duration) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Records the evaluation duration in milliseconds as metadata.
addOrUpdateMetadata(String name, String value) → void

Available on EvaluationMetric, provided by the EvaluationMetricExtensions extension

Sets a metadata entry.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited