llm/usage/
model_identity.rs1use crate::LlmModel;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5use super::ModelPricing;
6
7#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
10pub struct ModelIdentity {
11 pub provider: Option<String>,
12 pub model_id: Option<String>,
13 pub pricing: Option<ModelPricing>,
14}
15
16impl ModelIdentity {
17 pub fn of(model: Option<&LlmModel>) -> Self {
18 Self {
19 provider: model.map(|model| model.provider().to_string()),
20 model_id: model.map(|model| model.model_id().into_owned()),
21 pricing: model.and_then(LlmModel::pricing),
22 }
23 }
24}