systemprompt_provider_contracts/tool/
model_config.rs1use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, Hash)]
9pub struct ToolModelConfig {
10 #[serde(skip_serializing_if = "Option::is_none")]
11 pub provider: Option<String>,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub model: Option<String>,
14 #[serde(skip_serializing_if = "Option::is_none")]
15 pub max_output_tokens: Option<u32>,
16}
17
18impl ToolModelConfig {
19 pub fn new(provider: impl Into<String>, model: impl Into<String>) -> Self {
20 Self {
21 provider: Some(provider.into()),
22 model: Some(model.into()),
23 max_output_tokens: None,
24 }
25 }
26
27 pub const fn with_max_output_tokens(mut self, tokens: u32) -> Self {
28 self.max_output_tokens = Some(tokens);
29 self
30 }
31
32 pub const fn is_empty(&self) -> bool {
33 self.provider.is_none() && self.model.is_none() && self.max_output_tokens.is_none()
34 }
35
36 pub fn merge_with(&self, other: &Self) -> Self {
37 Self {
38 provider: other.provider.as_ref().or(self.provider.as_ref()).cloned(),
39 model: other.model.as_ref().or(self.model.as_ref()).cloned(),
40 max_output_tokens: other.max_output_tokens.or(self.max_output_tokens),
41 }
42 }
43}