Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(agent-cli): repair providers/tokamak after rebase onto dev

thinhlpg23cd878e028c
diff --git a/src-tauri/src/core/cli/providers.rs b/src-tauri/src/core/cli/providers.rs
index 9d2efbeb0..b89a5cd76 100644
--- a/src-tauri/src/core/cli/providers.rs
+++ b/src-tauri/src/core/cli/providers.rs
@@ -13,7 +13,7 @@
//! env fallback via [`ProviderOverrides::with_env`]) win over all of the
//! above - the most explicit, most ephemeral signal.
-use std::{collections::HashMap, path::Path};
+use std::{collections::HashMap, path::Path, time::Duration};
use crate::core::agent::global_config::load_global_config;
use crate::core::agent::project::ProviderSection;
@@ -313,6 +313,7 @@ pub async fn fetch_missing_models(
crate::core::agent::global_config::ProviderUpdate {
api_key: None,
base_url: None,
+ clear_api_key: false,
models: Some(models),
api_type: None,
},
@@ -964,6 +965,7 @@ mod tests {
crate::core::agent::global_config::ProviderUpdate {
api_key: Some("k".into()),
base_url: Some(format!("http://{addr}/v1")),
+ clear_api_key: false,
models: Some(vec![]),
api_type: None,
},
@@ -991,6 +993,7 @@ mod tests {
crate::core::agent::global_config::ProviderUpdate {
api_key: Some("k".into()),
base_url: Some("http://127.0.0.1:9/v1".into()), // would refuse
+ clear_api_key: false,
models: Some(vec!["my-model".into()]),
api_type: None,
},
@@ -1019,6 +1022,7 @@ mod tests {
crate::core::agent::global_config::ProviderUpdate {
api_key: None,
base_url: Some(format!("http://{addr}/v1")),
+ clear_api_key: false,
models: Some(vec![]),
api_type: None,
},
@@ -1068,6 +1072,7 @@ mod tests {
crate::core::agent::global_config::ProviderUpdate {
api_key: Some("k".into()),
base_url: Some(format!("http://{addr}/v1")),
+ clear_api_key: false,
models: Some(vec![]),
api_type: None,
},
@@ -1095,6 +1100,7 @@ mod tests {
crate::core::agent::global_config::ProviderUpdate {
api_key: Some("k".into()),
base_url: Some("http://127.0.0.1:9/v1".into()), // refuses instantly
+ clear_api_key: false,
models: Some(vec![]),
api_type: None,
},
diff --git a/src-tauri/src/core/cli/tokamak.rs b/src-tauri/src/core/cli/tokamak.rs
index 94e335e0c..fe5a4dda8 100644
--- a/src-tauri/src/core/cli/tokamak.rs
+++ b/src-tauri/src/core/cli/tokamak.rs
@@ -141,7 +141,7 @@ fn snippet(body: &str) -> String {
/// the "N models" report are stable across calls. Accepts the OpenAI shape
/// (`{"data":[{"id":...}]}`) plus the bare-array and array-of-strings variants
/// smaller gateways serve.
-fn parse_models(value: &serde_json::Value) -> Vec<String> {
+pub(crate) fn parse_models(value: &serde_json::Value) -> Vec<String> {
super::auth::providers::parse_models(value)
}