Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

3 changes: 3 additions & 0 deletions mofa-engine-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ tokio-stream = { workspace = true }
# Vetted 1.11.0 for the initial engine landing.
liter-llm = "=1.11.0"
base64 = "0.23.0"

[dev-dependencies]
axum = { workspace = true }
17 changes: 16 additions & 1 deletion mofa-engine-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,21 @@ pub struct ModelDef {
}

impl EngineConfig {
/// The config file the loader would use: MOFA_ENGINE_CONFIG
/// env > ./config.toml > ~/.config/mofa-engine/config.toml.
pub fn resolved_path() -> Option<std::path::PathBuf> {
if let Ok(explicit) = std::env::var("MOFA_ENGINE_CONFIG") {
if !explicit.is_empty() {
return Some(std::path::PathBuf::from(explicit));
}
}
let cwd = std::path::PathBuf::from("config.toml");
if cwd.exists() {
return Some(cwd);
}
dirs::config_dir().map(|d| d.join("mofa-engine").join("config.toml"))
}

/// Load configuration from the first available source.
///
/// Priority: explicit path > `./config.toml` > `~/.config/mofa-engine/config.toml` > env auto-detect.
Expand Down Expand Up @@ -759,7 +774,7 @@ impl ProviderConfig {
}

/// Parse the configured provider kind.
pub(crate) fn provider_kind(&self) -> Result<ProviderKind, EngineError> {
pub fn provider_kind(&self) -> Result<ProviderKind, EngineError> {
match self.kind.as_str() {
"ollama" => Ok(ProviderKind::Ollama),
"openai_compatible" => Ok(ProviderKind::OpenAiCompatible),
Expand Down
Loading