| | | 1 | | namespace NexusLabs.Needlr.AgentFramework.Langfuse; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Serializable payload for <c>POST /api/public/score-configs</c>. Property names are projected to |
| | | 5 | | /// camelCase by <see cref="LangfuseApiClient"/>. |
| | | 6 | | /// </summary> |
| | | 7 | | internal sealed record LangfuseScoreConfigRequest |
| | | 8 | | { |
| | | 9 | | /// <summary>Gets the score config name.</summary> |
| | 4 | 10 | | public required string Name { get; init; } |
| | | 11 | | |
| | | 12 | | /// <summary>Gets the Langfuse data-type token (<c>NUMERIC</c>, <c>BOOLEAN</c>, <c>CATEGORICAL</c>, <c>TEXT</c>).</s |
| | 4 | 13 | | public required string DataType { get; init; } |
| | | 14 | | |
| | | 15 | | /// <summary>Gets the categories for a categorical config, or <see langword="null"/>.</summary> |
| | 4 | 16 | | public IReadOnlyList<LangfuseScoreConfigCategory>? Categories { get; init; } |
| | | 17 | | |
| | | 18 | | /// <summary>Gets the inclusive minimum for numeric configs, or <see langword="null"/>.</summary> |
| | 4 | 19 | | public double? MinValue { get; init; } |
| | | 20 | | |
| | | 21 | | /// <summary>Gets the inclusive maximum for numeric configs, or <see langword="null"/>.</summary> |
| | 4 | 22 | | public double? MaxValue { get; init; } |
| | | 23 | | |
| | | 24 | | /// <summary>Gets the optional description.</summary> |
| | 4 | 25 | | public string? Description { get; init; } |
| | | 26 | | |
| | | 27 | | /// <summary>Projects a public <see cref="LangfuseScoreConfig"/> to the wire payload.</summary> |
| | | 28 | | /// <param name="config">The score config to project.</param> |
| | | 29 | | /// <returns>The request payload.</returns> |
| | | 30 | | public static LangfuseScoreConfigRequest From(LangfuseScoreConfig config) |
| | | 31 | | { |
| | 2 | 32 | | ArgumentNullException.ThrowIfNull(config); |
| | | 33 | | |
| | 2 | 34 | | var isNumeric = config.DataType == LangfuseScoreDataType.Numeric; |
| | 2 | 35 | | var isCategorical = config.DataType == LangfuseScoreDataType.Categorical; |
| | | 36 | | |
| | 2 | 37 | | return new LangfuseScoreConfigRequest |
| | 2 | 38 | | { |
| | 2 | 39 | | Name = config.Name, |
| | 2 | 40 | | DataType = config.DataType.ToLangfuseToken(), |
| | 2 | 41 | | Categories = isCategorical ? config.Categories : null, |
| | 2 | 42 | | MinValue = isNumeric ? config.MinValue : null, |
| | 2 | 43 | | MaxValue = isNumeric ? config.MaxValue : null, |
| | 2 | 44 | | Description = config.Description, |
| | 2 | 45 | | }; |
| | | 46 | | } |
| | | 47 | | } |