ILangfuseScoreClient
NexusLabs.Needlr.AgentFramework.Langfuse¶
ILangfuseScoreClient Interface¶
Records Langfuse scores against a known trace id. Registered in dependency injection by AddNeedlrLangfuse(this IServiceCollection, Action<LangfuseOptions>) for ASP.NET Core and generic-host applications that score their own request traces.
Remarks¶
In a host application the OTLP exporter assigns each operation an OpenTelemetry trace id
(Activity.Current?.TraceId). Pass that id here to attach evaluation scores to the
corresponding Langfuse trace. For the eval/console flow, prefer
BeginScenario(string, string, string, IEnumerable<string>, IReadOnlyDictionary<string,string>), which manages the trace for you.
Properties¶
ILangfuseScoreClient.IsEnabled Property¶
Gets a value indicating whether scores are being sent. false when Langfuse was not configured, in which case all record calls are no-ops.
Property Value¶
ILangfuseScoreClient.ScoresFailed Property¶
Gets the cumulative number of score uploads that have failed.
Property Value¶
Methods¶
ILangfuseScoreClient.RecordEvaluationAsync(string, EvaluationResult, CancellationToken) Method¶
Projects every metric in result to a Langfuse score against traceId, using the same mapping as RecordEvaluationAsync(EvaluationResult, CancellationToken).
System.Threading.Tasks.Task RecordEvaluationAsync(string traceId, Microsoft.Extensions.AI.Evaluation.EvaluationResult result, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
traceId System.String
The Langfuse/OpenTelemetry trace id to attach the scores to.
result Microsoft.Extensions.AI.Evaluation.EvaluationResult
The evaluation result to project.
cancellationToken System.Threading.CancellationToken
A cancellation token.
Returns¶
System.Threading.Tasks.Task
A task that completes when Langfuse has accepted all projected scores.
ILangfuseScoreClient.RecordScoreAsync(string, string, bool, string, CancellationToken) Method¶
Records a boolean score (stored as 1/0) against traceId.
System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, bool value, string? comment=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
traceId System.String
The Langfuse/OpenTelemetry trace id to attach the score to.
name System.String
The score name.
value System.Boolean
The boolean value.
comment System.String
An optional explanation surfaced in Langfuse.
cancellationToken System.Threading.CancellationToken
A cancellation token.
Returns¶
System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.
ILangfuseScoreClient.RecordScoreAsync(string, string, double, string, CancellationToken) Method¶
Records a numeric score against traceId.
System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, double value, string? comment=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
traceId System.String
The Langfuse/OpenTelemetry trace id to attach the score to.
name System.String
The score name.
value System.Double
The numeric value.
comment System.String
An optional explanation surfaced in Langfuse.
cancellationToken System.Threading.CancellationToken
A cancellation token.
Returns¶
System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.
ILangfuseScoreClient.RecordScoreAsync(string, string, string, string, CancellationToken) Method¶
Records a categorical score against traceId.
System.Threading.Tasks.Task RecordScoreAsync(string traceId, string name, string value, string? comment=null, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));
Parameters¶
traceId System.String
The Langfuse/OpenTelemetry trace id to attach the score to.
name System.String
The score name.
value System.String
The category label.
comment System.String
An optional explanation surfaced in Langfuse.
cancellationToken System.Threading.CancellationToken
A cancellation token.
Returns¶
System.Threading.Tasks.Task
A task that completes when Langfuse has accepted the score.