From d4087dbaf7208da5ae842ec5ba2e9c442bfa4f94 Mon Sep 17 00:00:00 2001 From: sigoden Date: Mon, 10 Feb 2025 08:01:21 +0800 Subject: feat: supports fetching models during configuration initialization (#1161) --- src/config/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/config/mod.rs') diff --git a/src/config/mod.rs b/src/config/mod.rs index 78f1e64..1ab500f 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -242,7 +242,7 @@ impl Default for Config { pub type GlobalConfig = Arc>; impl Config { - pub fn init(working_mode: WorkingMode, info_flag: bool) -> Result { + pub async fn init(working_mode: WorkingMode, info_flag: bool) -> Result { let config_path = Self::config_file(); let mut config = if !config_path.exists() { match env::var(get_env_name("provider")) @@ -252,7 +252,7 @@ impl Config { Some(v) => Self::load_dynamic(&v)?, None => { if *IS_STDOUT_TERMINAL { - create_config_file(&config_path)?; + create_config_file(&config_path).await?; } Self::load_from_file(&config_path)? } @@ -2604,7 +2604,7 @@ impl AssertState { } } -fn create_config_file(config_path: &Path) -> Result<()> { +async fn create_config_file(config_path: &Path) -> Result<()> { let ans = Confirm::new("No config file, create a new one?") .with_default(true) .prompt()?; @@ -2615,7 +2615,7 @@ fn create_config_file(config_path: &Path) -> Result<()> { let client = Select::new("API Provider (required):", list_client_types()).prompt()?; let mut config = serde_json::json!({}); - let (model, clients_config) = create_client_config(client)?; + let (model, clients_config) = create_client_config(client).await?; config["model"] = model.into(); config[CLIENTS_FIELD] = clients_config; -- cgit v1.2.3