langfuse_client_base/models/
model.rs1use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Model {
17 #[serde(rename = "id")]
18 pub id: String,
19 #[serde(rename = "modelName")]
21 pub model_name: String,
22 #[serde(rename = "matchPattern")]
24 pub match_pattern: String,
25 #[serde(
27 rename = "startDate",
28 default,
29 with = "::serde_with::rust::double_option",
30 skip_serializing_if = "Option::is_none"
31 )]
32 pub start_date: Option<Option<String>>,
33 #[serde(rename = "unit", skip_serializing_if = "Option::is_none")]
34 pub unit: Option<models::ModelUsageUnit>,
35 #[serde(
37 rename = "inputPrice",
38 default,
39 with = "::serde_with::rust::double_option",
40 skip_serializing_if = "Option::is_none"
41 )]
42 pub input_price: Option<Option<f64>>,
43 #[serde(
45 rename = "outputPrice",
46 default,
47 with = "::serde_with::rust::double_option",
48 skip_serializing_if = "Option::is_none"
49 )]
50 pub output_price: Option<Option<f64>>,
51 #[serde(
53 rename = "totalPrice",
54 default,
55 with = "::serde_with::rust::double_option",
56 skip_serializing_if = "Option::is_none"
57 )]
58 pub total_price: Option<Option<f64>>,
59 #[serde(
61 rename = "tokenizerId",
62 default,
63 with = "::serde_with::rust::double_option",
64 skip_serializing_if = "Option::is_none"
65 )]
66 pub tokenizer_id: Option<Option<String>>,
67 #[serde(
69 rename = "tokenizerConfig",
70 default,
71 with = "::serde_with::rust::double_option",
72 skip_serializing_if = "Option::is_none"
73 )]
74 pub tokenizer_config: Option<Option<serde_json::Value>>,
75 #[serde(rename = "isLangfuseManaged")]
76 pub is_langfuse_managed: bool,
77 #[serde(rename = "prices")]
79 pub prices: std::collections::HashMap<String, models::ModelPrice>,
80}
81
82impl Model {
83 pub fn new(
85 id: String,
86 model_name: String,
87 match_pattern: String,
88 is_langfuse_managed: bool,
89 prices: std::collections::HashMap<String, models::ModelPrice>,
90 ) -> Model {
91 Model {
92 id,
93 model_name,
94 match_pattern,
95 start_date: None,
96 unit: None,
97 input_price: None,
98 output_price: None,
99 total_price: None,
100 tokenizer_id: None,
101 tokenizer_config: None,
102 is_langfuse_managed,
103 prices,
104 }
105 }
106}