langfuse_client/models/
model.rs

1/*
2 * langfuse
3 *
4 * ## Authentication  Authenticate with the API using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication), get API keys in the project settings:  - username: Langfuse Public Key - password: Langfuse Secret Key  ## Exports  - OpenAPI spec: https://cloud.langfuse.com/generated/api/openapi.yml - Postman collection: https://cloud.langfuse.com/generated/postman/collection.json
5 *
6 * The version of the OpenAPI document: 
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Model : Model definition used for transforming usage into USD cost and/or tokenization.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Model {
17    #[serde(rename = "id")]
18    pub id: String,
19    /// Name of the model definition. If multiple with the same name exist, they are applied in the following order: (1) custom over built-in, (2) newest according to startTime where model.startTime<observation.startTime
20    #[serde(rename = "modelName")]
21    pub model_name: String,
22    /// Regex pattern which matches this model definition to generation.model. Useful in case of fine-tuned models. If you want to exact match, use `(?i)^modelname$`
23    #[serde(rename = "matchPattern")]
24    pub match_pattern: String,
25    /// Apply only to generations which are newer than this ISO date.
26    #[serde(rename = "startDate", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
27    pub start_date: Option<Option<String>>,
28    #[serde(rename = "unit", skip_serializing_if = "Option::is_none")]
29    pub unit: Option<models::ModelUsageUnit>,
30    /// Price (USD) per input unit
31    #[serde(rename = "inputPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
32    pub input_price: Option<Option<f64>>,
33    /// Price (USD) per output unit
34    #[serde(rename = "outputPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
35    pub output_price: Option<Option<f64>>,
36    /// Price (USD) per total unit. Cannot be set if input or output price is set.
37    #[serde(rename = "totalPrice", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
38    pub total_price: Option<Option<f64>>,
39    /// Optional. Tokenizer to be applied to observations which match to this model. See docs for more details.
40    #[serde(rename = "tokenizerId", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
41    pub tokenizer_id: Option<Option<String>>,
42    /// Optional. Configuration for the selected tokenizer. Needs to be JSON. See docs for more details.
43    #[serde(rename = "tokenizerConfig", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
44    pub tokenizer_config: Option<Option<serde_json::Value>>,
45    #[serde(rename = "isLangfuseManaged")]
46    pub is_langfuse_managed: bool,
47}
48
49impl Model {
50    /// Model definition used for transforming usage into USD cost and/or tokenization.
51    pub fn new(id: String, model_name: String, match_pattern: String, is_langfuse_managed: bool) -> Model {
52        Model {
53            id,
54            model_name,
55            match_pattern,
56            start_date: None,
57            unit: None,
58            input_price: None,
59            output_price: None,
60            total_price: None,
61            tokenizer_id: None,
62            tokenizer_config: None,
63            is_langfuse_managed,
64        }
65    }
66}
67