Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored and antimonyGu committed Oct 23, 2024
1 parent a5e24e1 commit c7eed9e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions crates/tabby-common/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use std::{collections::HashSet, path::PathBuf};
use std::{collections::HashSet, path::PathBuf, process};

use anyhow::{anyhow, Context, Result};
use derive_builder::Builder;
use hash_ids::HashIds;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use tracing::debug;
use crate::config;
use std::process;

use crate::{
api::code::CodeSearchParams,
config,
languages,
path::repositories_dir,
terminal::{HeaderFormat, InfoMessage},
Expand Down Expand Up @@ -66,7 +65,7 @@ impl Config {
)
.print();
}

if let Err(e) = cfg.validate_config() {
cfg = Default::default();
InfoMessage::new(
Expand Down Expand Up @@ -105,22 +104,24 @@ impl Config {
Ok(())
}

fn validate_config(&self) -> Result<()> {
fn validate_config(&self) -> Result<()> {
Self::validate_model_config(&self.model.completion)?;
Self::validate_model_config(&self.model.chat)?;

Ok(())
}

fn validate_model_config(model_config: &Option<ModelConfig>) -> Result<()> {
if let Some(config::ModelConfig::Http(completion_http_config)) = &model_config
{
if let Some(config::ModelConfig::Http(completion_http_config)) = &model_config {
if let Some(models) = &completion_http_config.supported_models {
if let Some(model_name) = &completion_http_config.model_name {
if !models.contains(model_name) {
return Err(anyhow!("Suppported model list does not contain model: {}", model_name));
return Err(anyhow!(
"Suppported model list does not contain model: {}",
model_name
));
}
}
}
}
}

Expand Down

0 comments on commit c7eed9e

Please sign in to comment.