Skip to content

Commit

Permalink
Merge pull request #4899 from systeminit/jkeiser/remove-optional-params
Browse files Browse the repository at this point in the history
Remove optional parameters from service.toml
  • Loading branch information
jkeiser authored Oct 31, 2024
2 parents ca9f512 + f2a76d8 commit ce0d66f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions component/init/configs/service.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ url = "$SI_NATS_URL"

[openai]
api_key = "$SI_OPENAI_API_KEY"
api_base = "$SI_OPENAI_API_BASE"
api_version = "$SI_OPENAI_API_VERSION"
org_id = "$SI_OPENAI_ORG_ID"

[asset_sprayer]
prompts_dir = "$SI_ASSET_SPRAYER_PROMPTS_DIR"

[pg]
user = "si"
Expand Down
1 change: 1 addition & 0 deletions lib/asset-sprayer/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust_library(
"//third-party/rust:remain",
"//third-party/rust:reqwest",
"//third-party/rust:serde",
"//third-party/rust:serde_with",
"//third-party/rust:serde_yaml",
"//third-party/rust:strum",
"//third-party/rust:thiserror",
Expand Down
1 change: 1 addition & 0 deletions lib/asset-sprayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ include_dir = { workspace = true }
remain = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_with = { workspace = true }
serde_yaml = { workspace = true }
si-std = { path = "../../lib/si-std" }
strum = { workspace = true }
Expand Down
11 changes: 9 additions & 2 deletions lib/asset-sprayer/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
use async_openai::config::OpenAIConfig;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, NoneAsEmptyString};
use si_std::SensitiveString;
use std::path::PathBuf;

/// OpenAI configuration. Mirrors OpenAI configuration, but with Deserialize support.
#[serde_as]
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct SIOpenAIConfig {
#[serde_as(as = "NoneAsEmptyString")]
api_key: Option<SensitiveString>,
#[serde_as(as = "NoneAsEmptyString")]
api_base: Option<String>,
#[serde_as(as = "NoneAsEmptyString")]
org_id: Option<String>,
#[serde_as(as = "NoneAsEmptyString")]
project_id: Option<String>,
}

#[serde_as]
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct AssetSprayerConfig {
pub prompts_dir: Option<PathBuf>,
#[serde_as(as = "NoneAsEmptyString")]
pub prompts_dir: Option<String>,
}

impl SIOpenAIConfig {
Expand Down
2 changes: 1 addition & 1 deletion lib/asset-sprayer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl AssetSprayer {
) -> Self {
Self {
openai_client,
prompts: Prompts::new(config.prompts_dir),
prompts: Prompts::new(config.prompts_dir.map(Into::into)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/si-settings/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ rust_library(
name = "si-settings",
deps = [
"//lib/config-file:config-file",
"//lib/si-std:si-std",
"//third-party/rust:remain",
"//third-party/rust:serde",
"//third-party/rust:serde_with",
"//third-party/rust:thiserror",
],
srcs = glob(["src/**/*.rs"]),
Expand Down

0 comments on commit ce0d66f

Please sign in to comment.