Skip to content

Commit 950645f

Browse files
committed
ordered code_completion_models and code_chat_models
1 parent 2e7da6d commit 950645f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

refact-agent/engine/src/caps.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::path::PathBuf;
22
use std::collections::HashMap;
3+
use indexmap::IndexMap;
34
use std::fs::File;
45
use std::io::Read;
56
use std::sync::Arc;
@@ -25,7 +26,7 @@ pub struct ModelRecord {
2526
#[serde(default)]
2627
pub n_ctx: usize,
2728
#[serde(default)]
28-
pub supports_scratchpads: HashMap<String, serde_json::Value>,
29+
pub supports_scratchpads: HashMap<String, Value>,
2930
#[serde(default)]
3031
pub default_scratchpad: String,
3132
#[serde(default)]
@@ -42,8 +43,8 @@ pub struct ModelRecord {
4243

4344
#[derive(Debug, Deserialize)]
4445
pub struct ModelsOnly {
45-
pub code_completion_models: HashMap<String, ModelRecord>,
46-
pub code_chat_models: HashMap<String, ModelRecord>,
46+
pub code_completion_models: IndexMap<String, ModelRecord>,
47+
pub code_chat_models: IndexMap<String, ModelRecord>,
4748
pub tokenizer_rewrite_path: HashMap<String, String>,
4849
}
4950

@@ -110,7 +111,7 @@ pub struct CodeAssistantCaps {
110111
#[serde(default = "default_telemetry_basic_retrieve_my_own")]
111112
pub telemetry_basic_retrieve_my_own: String,
112113
#[serde(default)]
113-
pub code_completion_models: HashMap<String, ModelRecord>,
114+
pub code_completion_models: IndexMap<String, ModelRecord>,
114115
#[serde(default)]
115116
#[serde(alias = "completion_model")]
116117
pub code_completion_default_model: String,
@@ -121,7 +122,7 @@ pub struct CodeAssistantCaps {
121122
#[serde(alias = "completion_n_ctx")]
122123
pub code_completion_n_ctx: usize,
123124
#[serde(default)]
124-
pub code_chat_models: HashMap<String, ModelRecord>,
125+
pub code_chat_models: IndexMap<String, ModelRecord>,
125126
#[serde(default)]
126127
#[serde(alias = "chat_model")]
127128
pub code_chat_default_model: String,
@@ -463,7 +464,7 @@ fn _inherit_r1_from_r0(
463464
}
464465

465466
pub fn which_model_to_use<'a>(
466-
models: &'a HashMap<String, ModelRecord>,
467+
models: &'a IndexMap<String, ModelRecord>,
467468
user_wants_model: &str,
468469
default_model: &str,
469470
) -> Result<(String, &'a ModelRecord), String> {
@@ -473,15 +474,15 @@ pub fn which_model_to_use<'a>(
473474
}
474475
let no_finetune = strip_model_from_finetune(&take_this_one.to_string());
475476
if let Some(model_rec) = models.get(&take_this_one.to_string()) {
476-
return Ok((take_this_one.to_string(), model_rec));
477+
Ok((take_this_one.to_string(), model_rec))
477478
} else if let Some(model_rec) = models.get(&no_finetune) {
478-
return Ok((take_this_one.to_string(), model_rec));
479+
Ok((take_this_one.to_string(), model_rec))
479480
} else {
480-
return Err(format!(
481+
Err(format!(
481482
"Model '{}' not found. Server has these models: {:?}",
482483
take_this_one,
483484
models.keys()
484-
));
485+
))
485486
}
486487
}
487488

0 commit comments

Comments
 (0)