LangfuseEvaluationScoreExtensions
NexusLabs.Foundry.Langfuse¶
LangfuseEvaluationScoreExtensions Class¶
Convenience extensions for projecting Microsoft.Extensions.AI.Evaluation results onto a
Langfuse scenario trace as scores.
Inheritance System.Object 🡒 LangfuseEvaluationScoreExtensions
Methods¶
LangfuseEvaluationScoreExtensions.EvaluateAndRecordAsync(this ILangfuseScenario, IEnumerable<IEvaluator>, IEnumerable<ChatMessage>, ChatResponse) Method¶
Runs each evaluator over the supplied agent output and records every resulting metric as a Langfuse score on the scenario's trace using default evaluator and score configuration.
public static System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.Evaluation.EvaluationResult>> EvaluateAndRecordAsync(this NexusLabs.Foundry.Langfuse.ILangfuseScenario scenario, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.Evaluation.IEvaluator> evaluators, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, Microsoft.Extensions.AI.ChatResponse modelResponse);
Parameters¶
scenario ILangfuseScenario
The scenario whose trace the scores attach to.
evaluators System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.Evaluation.IEvaluator>
The evaluators to run.
messages System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>
The conversation messages sent to the agent (for example, from EvaluationInputs.Messages).
modelResponse Microsoft.Extensions.AI.ChatResponse
The agent's response (for example, from EvaluationInputs.ModelResponse).
Returns¶
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.Evaluation.EvaluationResult>>
The evaluation results, in evaluator order.
Exceptions¶
System.ArgumentNullException
scenario, evaluators, messages, or
modelResponse is null.
LangfuseEvaluationScoreExtensions.EvaluateAndRecordAsync(this ILangfuseScenario, IEnumerable<IEvaluator>, IEnumerable<ChatMessage>, ChatResponse, LangfuseEvaluateAndRecordOptions, CancellationToken) Method¶
Runs each evaluator over the supplied agent output and records every resulting metric as a Langfuse score on the scenario's trace using explicit evaluator, score, and cancellation configuration.
public static System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.Evaluation.EvaluationResult>> EvaluateAndRecordAsync(this NexusLabs.Foundry.Langfuse.ILangfuseScenario scenario, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.Evaluation.IEvaluator> evaluators, System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage> messages, Microsoft.Extensions.AI.ChatResponse modelResponse, NexusLabs.Foundry.Langfuse.LangfuseEvaluateAndRecordOptions options, System.Threading.CancellationToken cancellationToken);
Parameters¶
scenario ILangfuseScenario
The scenario whose trace the scores attach to.
evaluators System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.Evaluation.IEvaluator>
The evaluators to run.
messages System.Collections.Generic.IEnumerable<Microsoft.Extensions.AI.ChatMessage>
The conversation messages sent to the agent (for example, from EvaluationInputs.Messages).
modelResponse Microsoft.Extensions.AI.ChatResponse
The agent's response (for example, from EvaluationInputs.ModelResponse).
options LangfuseEvaluateAndRecordOptions
The evaluator execution and score projection configuration.
cancellationToken System.Threading.CancellationToken
A cancellation token.
Returns¶
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Microsoft.Extensions.AI.Evaluation.EvaluationResult>>
The evaluation results, in evaluator order.
Exceptions¶
System.ArgumentNullException
scenario, evaluators, messages,
modelResponse, or options is
null.
LangfuseEvaluationScoreExtensions.RecordLangfuseScoresAsync(this EvaluationResult, ILangfuseScenario) Method¶
Records every metric in result as a Langfuse score on scenario's trace. Equivalent to RecordEvaluationAsync(EvaluationResult), provided as a fluent call site for eval code that already holds an Microsoft.Extensions.AI.Evaluation.EvaluationResult.
public static System.Threading.Tasks.Task RecordLangfuseScoresAsync(this Microsoft.Extensions.AI.Evaluation.EvaluationResult result, NexusLabs.Foundry.Langfuse.ILangfuseScenario scenario);
Parameters¶
result Microsoft.Extensions.AI.Evaluation.EvaluationResult
The evaluation result to project.
scenario ILangfuseScenario
The scenario whose trace the scores attach to.
Returns¶
System.Threading.Tasks.Task
A task that completes when Langfuse has accepted all projected scores.
Exceptions¶
System.ArgumentNullException
result or scenario is null.
LangfuseEvaluationScoreExtensions.RecordLangfuseScoresAsync(this EvaluationResult, ILangfuseScenario, LangfuseEvaluationScoreOptions, CancellationToken) Method¶
Records every metric in result as a Langfuse score on scenario's trace. Equivalent to RecordEvaluationAsync(EvaluationResult, LangfuseEvaluationScoreOptions, CancellationToken), provided as a fluent call site for eval code that already holds an Microsoft.Extensions.AI.Evaluation.EvaluationResult.
public static System.Threading.Tasks.Task RecordLangfuseScoresAsync(this Microsoft.Extensions.AI.Evaluation.EvaluationResult result, NexusLabs.Foundry.Langfuse.ILangfuseScenario scenario, NexusLabs.Foundry.Langfuse.LangfuseEvaluationScoreOptions? options, System.Threading.CancellationToken cancellationToken);
Parameters¶
result Microsoft.Extensions.AI.Evaluation.EvaluationResult
The evaluation result to project.
scenario ILangfuseScenario
The scenario whose trace the scores attach to.
options LangfuseEvaluationScoreOptions
Stable identity settings for projected metric scores, or null.
cancellationToken System.Threading.CancellationToken
A cancellation token.
Returns¶
System.Threading.Tasks.Task
A task that completes when Langfuse has accepted all projected scores.