Skip to main content

systemprompt_models/ai/
models.rs

1//! Model configuration for tool-calling and chat requests.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8use systemprompt_identifiers::ModelId;
9
10pub use systemprompt_provider_contracts::ToolModelConfig;
11
12pub type ToolModelOverrides = HashMap<String, HashMap<String, ToolModelConfig>>;
13
14#[derive(Debug, Clone, Serialize, Deserialize)]
15pub struct ModelConfig {
16    pub id: ModelId,
17    pub max_tokens: u32,
18    pub supports_tools: bool,
19    #[serde(default)]
20    pub cost_per_1k_tokens: f32,
21}
22
23impl ModelConfig {
24    pub const fn new(id: ModelId, max_tokens: u32, supports_tools: bool) -> Self {
25        Self {
26            id,
27            max_tokens,
28            supports_tools,
29            cost_per_1k_tokens: 0.0,
30        }
31    }
32
33    pub const fn with_cost(mut self, cost: f32) -> Self {
34        self.cost_per_1k_tokens = cost;
35        self
36    }
37}