langfuse_rs/models/
numeric_score.rs1use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct NumericScore {
16 #[serde(rename = "value")]
18 pub value: f64,
19 #[serde(rename = "id")]
20 pub id: String,
21 #[serde(rename = "traceId")]
22 pub trace_id: String,
23 #[serde(rename = "name")]
24 pub name: String,
25 #[serde(rename = "source")]
26 pub source: models::ScoreSource,
27 #[serde(
28 rename = "observationId",
29 default,
30 with = "::serde_with::rust::double_option",
31 skip_serializing_if = "Option::is_none"
32 )]
33 pub observation_id: Option<Option<String>>,
34 #[serde(rename = "timestamp")]
35 pub timestamp: String,
36 #[serde(rename = "createdAt")]
37 pub created_at: String,
38 #[serde(rename = "updatedAt")]
39 pub updated_at: String,
40 #[serde(
41 rename = "authorUserId",
42 default,
43 with = "::serde_with::rust::double_option",
44 skip_serializing_if = "Option::is_none"
45 )]
46 pub author_user_id: Option<Option<String>>,
47 #[serde(
48 rename = "comment",
49 default,
50 with = "::serde_with::rust::double_option",
51 skip_serializing_if = "Option::is_none"
52 )]
53 pub comment: Option<Option<String>>,
54 #[serde(
56 rename = "configId",
57 default,
58 with = "::serde_with::rust::double_option",
59 skip_serializing_if = "Option::is_none"
60 )]
61 pub config_id: Option<Option<String>>,
62 #[serde(
64 rename = "queueId",
65 default,
66 with = "::serde_with::rust::double_option",
67 skip_serializing_if = "Option::is_none"
68 )]
69 pub queue_id: Option<Option<String>>,
70}
71
72impl NumericScore {
73 pub fn new(
74 value: f64,
75 id: String,
76 trace_id: String,
77 name: String,
78 source: models::ScoreSource,
79 timestamp: String,
80 created_at: String,
81 updated_at: String,
82 ) -> NumericScore {
83 NumericScore {
84 value,
85 id,
86 trace_id,
87 name,
88 source,
89 observation_id: None,
90 timestamp,
91 created_at,
92 updated_at,
93 author_user_id: None,
94 comment: None,
95 config_id: None,
96 queue_id: None,
97 }
98 }
99}