evals: Make LLMs configurable in edit_agent evals (#30813)
Release Notes: - N/A
This commit is contained in:
parent
dcf7f714f7
commit
5112fcebeb
2 changed files with 46 additions and 10 deletions
|
@ -4,7 +4,7 @@ use crate::{
|
|||
};
|
||||
use collections::BTreeMap;
|
||||
use gpui::{App, Context, Entity, EventEmitter, Global, prelude::*};
|
||||
use std::sync::Arc;
|
||||
use std::{str::FromStr, sync::Arc};
|
||||
use util::maybe;
|
||||
|
||||
pub fn init(cx: &mut App) {
|
||||
|
@ -27,11 +27,36 @@ pub struct LanguageModelRegistry {
|
|||
inline_alternatives: Vec<Arc<dyn LanguageModel>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SelectedModel {
|
||||
pub provider: LanguageModelProviderId,
|
||||
pub model: LanguageModelId,
|
||||
}
|
||||
|
||||
impl FromStr for SelectedModel {
|
||||
type Err = String;
|
||||
|
||||
/// Parse string identifiers like `provider_id/model_id` into a `SelectedModel`
|
||||
fn from_str(id: &str) -> Result<SelectedModel, Self::Err> {
|
||||
let parts: Vec<&str> = id.split('/').collect();
|
||||
let [provider_id, model_id] = parts.as_slice() else {
|
||||
return Err(format!(
|
||||
"Invalid model identifier format: `{}`. Expected `provider_id/model_id`",
|
||||
id
|
||||
));
|
||||
};
|
||||
|
||||
if provider_id.is_empty() || model_id.is_empty() {
|
||||
return Err(format!("Provider and model ids can't be empty: `{}`", id));
|
||||
}
|
||||
|
||||
Ok(SelectedModel {
|
||||
provider: LanguageModelProviderId(provider_id.to_string().into()),
|
||||
model: LanguageModelId(model_id.to_string().into()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ConfiguredModel {
|
||||
pub provider: Arc<dyn LanguageModelProvider>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue