Skip to content

Commit 5e1233c

Browse files
committed
chore: decorates model with description (#3057)
1 parent 1dd1004 commit 5e1233c

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

crates/chat-cli/src/cli/chat/cli/model.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ pub struct ModelInfo {
2727
/// Display name
2828
#[serde(skip_serializing_if = "Option::is_none")]
2929
pub model_name: Option<String>,
30+
/// Description of the model
31+
#[serde(skip_serializing_if = "Option::is_none")]
32+
pub description: Option<String>,
3033
/// Actual model id to send in the API
3134
pub model_id: String,
3235
/// Size of the model's context window, in tokens
@@ -42,6 +45,7 @@ impl ModelInfo {
4245
.map_or(default_context_window(), |tokens| tokens as usize);
4346
Self {
4447
model_id: model.model_id().to_string(),
48+
description: model.description.clone(),
4549
model_name: model.model_name().map(|s| s.to_string()),
4650
context_window_tokens,
4751
}
@@ -51,6 +55,7 @@ impl ModelInfo {
5155
pub fn from_id(model_id: String) -> Self {
5256
Self {
5357
model_id,
58+
description: None,
5459
model_name: None,
5560
context_window_tokens: 200_000,
5661
}
@@ -59,6 +64,12 @@ impl ModelInfo {
5964
pub fn display_name(&self) -> &str {
6065
self.model_name.as_deref().unwrap_or(&self.model_id)
6166
}
67+
68+
pub fn description(&self) -> Option<&str> {
69+
self.description
70+
.as_deref()
71+
.and_then(|d| if d.is_empty() { None } else { Some(d) })
72+
}
6273
}
6374

6475
/// Command-line arguments for model selection operations
@@ -95,10 +106,17 @@ pub async fn select_model(os: &Os, session: &mut ChatSession) -> Result<Option<C
95106
.iter()
96107
.map(|model| {
97108
let display_name = model.display_name();
109+
let description = model.description();
98110
if Some(model.model_id.as_str()) == active_model_id {
99-
format!("{} (active)", display_name)
111+
if let Some(desc) = description {
112+
format!("{} (active) | {}", display_name, desc)
113+
} else {
114+
format!("{} (active)", display_name)
115+
}
116+
} else if let Some(desc) = description {
117+
format!("{} | {}", display_name, desc)
100118
} else {
101-
display_name.to_owned()
119+
display_name.to_string()
102120
}
103121
})
104122
.collect();
@@ -194,11 +212,13 @@ fn get_fallback_models() -> Vec<ModelInfo> {
194212
ModelInfo {
195213
model_name: Some("claude-sonnet-4".to_string()),
196214
model_id: "claude-sonnet-4".to_string(),
215+
description: None,
197216
context_window_tokens: 200_000,
198217
},
199218
ModelInfo {
200219
model_name: Some("claude-3.7-sonnet".to_string()),
201220
model_id: "claude-3.7-sonnet".to_string(),
221+
description: None,
202222
context_window_tokens: 200_000,
203223
},
204224
]

crates/chat-cli/src/cli/chat/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ mod tests {
443443
assert_eq!(
444444
calc_max_context_files_size(Some(&ModelInfo {
445445
model_id: "CLAUDE_SONNET_4_20250514_V1_0".to_string(),
446+
description: None,
446447
model_name: Some("Claude".to_string()),
447448
context_window_tokens: 200_000,
448449
})),
@@ -451,6 +452,7 @@ mod tests {
451452
assert_eq!(
452453
calc_max_context_files_size(Some(&ModelInfo {
453454
model_id: "OPENAI_GPT_OSS_120B_1_0".to_string(),
455+
description: None,
454456
model_name: Some("GPT".to_string()),
455457
context_window_tokens: 128_000,
456458
})),

0 commit comments

Comments
 (0)