| | | 1 | | namespace NexusLabs.Needlr.AgentFramework.Langfuse; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Serializable payload for a single Langfuse score ingested via the public Scores API. |
| | | 5 | | /// </summary> |
| | | 6 | | /// <remarks> |
| | | 7 | | /// Property names are projected to camelCase by the score client to match the Langfuse REST |
| | | 8 | | /// contract. <see cref="Value"/> is a <see cref="double"/> for numeric and boolean scores and a |
| | | 9 | | /// <see cref="string"/> for categorical and text scores. |
| | | 10 | | /// </remarks> |
| | | 11 | | internal sealed record LangfuseScore |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets the id of the trace the score is attached to. Optional: a score may instead target a |
| | | 15 | | /// session (<see cref="SessionId"/>) or dataset run (<see cref="DatasetRunId"/>). Required when |
| | | 16 | | /// <see cref="ObservationId"/> is set. |
| | | 17 | | /// </summary> |
| | 25 | 18 | | public string? TraceId { get; init; } |
| | | 19 | | |
| | | 20 | | /// <summary>Gets the score name (for example an evaluator metric name). Required.</summary> |
| | 28 | 21 | | public required string Name { get; init; } |
| | | 22 | | |
| | | 23 | | /// <summary>Gets the score value: a number for numeric/boolean, a string for categorical/text.</summary> |
| | 25 | 24 | | public required object Value { get; init; } |
| | | 25 | | |
| | | 26 | | /// <summary>Gets the Langfuse data type token (<c>NUMERIC</c>, <c>BOOLEAN</c>, <c>CATEGORICAL</c>, <c>TEXT</c>).</s |
| | 25 | 27 | | public required string DataType { get; init; } |
| | | 28 | | |
| | | 29 | | /// <summary>Gets the optional id of a specific observation within the trace to attach the score to.</summary> |
| | 22 | 30 | | public string? ObservationId { get; init; } |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the optional id of a session to attach the score to (session-level scoring).</summary> |
| | 22 | 33 | | public string? SessionId { get; init; } |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the optional id of a dataset run to attach the score to (experiment-level scoring).</summary> |
| | 11 | 36 | | public string? DatasetRunId { get; init; } |
| | | 37 | | |
| | | 38 | | /// <summary>Gets the optional free-text comment that accompanies the score.</summary> |
| | 23 | 39 | | public string? Comment { get; init; } |
| | | 40 | | |
| | | 41 | | /// <summary>Gets the optional client-supplied id used as an idempotency key.</summary> |
| | 11 | 42 | | public string? Id { get; init; } |
| | | 43 | | } |