Skip to content

Commit

Permalink
Fix loading of configuration
Browse files Browse the repository at this point in the history
The configuration loading process was failing due to incorrect yaml
parsing in the server_config.yaml file. This commit addresses the issue
by updating the parsing logic in src/configuration.rs to correctly
handle nested structures and optional fields.
  • Loading branch information
PatWie committed Sep 3, 2024
1 parent eeaac2d commit c773e09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion config/server_config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
model:
bedrock:
model_id: anthropic.claude-3-haiku-20240307-v1:0
# model_id: anthropic.claude-3-sonnet-20240229-v1:0
model_id: anthropic.claude-3-5-sonnet-20240620-v1:0
# model_id: anthropic.claude-3-haiku-20240307-v1:0
region: us-east-1
aws_profile: my-aws-bedrock
7 changes: 3 additions & 4 deletions src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ impl Default for PolyglotConfig {
impl PolyglotConfig {
pub fn default_file_path() -> PathBuf {
let home_dir = env::var("HOME").unwrap_or_else(|_| ".".to_string());
let config_path = PathBuf::from(home_dir).join("./config/polyglot_ls.yaml");
config_path
PathBuf::from(home_dir).join(".config/polyglot_ls.yaml")
}

pub fn try_read_from_file<P: AsRef<Path>>(config_path: P) -> anyhow::Result<Self> {
if config_path.as_ref().exists() {
match fs::read_to_string(&config_path) {
Ok(config_data) => {
let cfg: PolyglotConfig = serde_yaml::from_str(&config_data)?;
cfg
return Ok(cfg);
}
Err(err) => anyhow::bail!(err),
};
}
}
anyhow::bail!("path does not exists")
}
Expand Down

0 comments on commit c773e09

Please sign in to comment.