Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions app/src/ai/llms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn is_using_api_key_for_provider(provider: &LLMProvider, app: &AppContext) -
LLMProvider::OpenAI => api_keys.is_some_and(|keys| keys.openai.is_some()),
LLMProvider::Anthropic => api_keys.is_some_and(|keys| keys.anthropic.is_some()),
LLMProvider::Google => api_keys.is_some_and(|keys| keys.google.is_some()),
LLMProvider::Ollama => api_keys.is_some_and(|keys| keys.ollama_url.is_some()),
_ => false,
}
}
Expand Down Expand Up @@ -89,6 +90,7 @@ pub enum LLMProvider {
Anthropic,
Google,
Xai,
Ollama,
Unknown,
}

Expand All @@ -100,6 +102,7 @@ impl LLMProvider {
LLMProvider::Anthropic => Some(Icon::ClaudeLogo),
LLMProvider::Google => Some(Icon::GeminiLogo),
LLMProvider::Xai => None,
LLMProvider::Ollama => None, // TODO: Add Ollama icon
LLMProvider::Unknown => None,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/ai/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ derivative.workspace = true
warp_core.workspace = true
warp_terminal.workspace = true
warp_util.workspace = true
reqwest.workspace = true
chrono.workspace = true
persistence.workspace = true
priority-queue = "2.3.1"
Expand Down
15 changes: 15 additions & 0 deletions crates/ai/src/api_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub struct ApiKeys {
pub anthropic: Option<String>,
pub openai: Option<String>,
pub open_router: Option<String>,
/// Ollama URL (e.g., "http://localhost:11434"). No API key needed.
pub ollama_url: Option<String>,
}

impl ApiKeys {
Expand All @@ -30,6 +32,7 @@ impl ApiKeys {
|| self.anthropic.is_some()
|| self.google.is_some()
|| self.open_router.is_some()
|| self.ollama_url.is_some()
}
}

Expand Down Expand Up @@ -93,6 +96,12 @@ impl ApiKeyManager {
self.write_keys_to_secure_storage(ctx);
}

pub fn set_ollama_url(&mut self, url: Option<String>, ctx: &mut ModelContext<Self>) {
self.keys.ollama_url = url;
ctx.emit(ApiKeyManagerEvent::KeysUpdated);
self.write_keys_to_secure_storage(ctx);
}

pub fn set_aws_credentials_state(
&mut self,
state: AwsCredentialsState,
Expand Down Expand Up @@ -138,6 +147,10 @@ impl ApiKeyManager {
.then(|| self.keys.open_router.clone())
.flatten()
.unwrap_or_default();
let ollama_url = include_byo_keys
.then(|| self.keys.ollama_url.clone())
.flatten()
.unwrap_or_default();
// Also include credentials when running with OIDC-managed Bedrock inference, regardless
// of the per-user setting flag (which only applies to the local credential chain path).
let include_aws = include_aws_bedrock_credentials
Expand All @@ -158,6 +171,7 @@ impl ApiKeyManager {
&& openai.is_empty()
&& google.is_empty()
&& open_router.is_empty()
&& ollama_url.is_empty()
&& aws_credentials.is_none()
{
None
Expand All @@ -167,6 +181,7 @@ impl ApiKeyManager {
openai,
google,
open_router,
ollama_url,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] This initializes the generated warp_multi_agent_api::request::settings::ApiKeys with ollama_url, but this PR does not update that generated type, so cargo check -p ai will fail; additionally, local Ollama URLs should not be sent through remote request settings.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Removed ollama_url from api_keys_for_request() since local Ollama endpoints should never be sent through remote request settings.

allow_use_of_warp_credits: false,
aws_credentials,
})
Expand Down
1 change: 1 addition & 0 deletions crates/ai/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod agent;
pub mod api_keys;
pub mod aws_credentials;
pub mod llm_id;
pub mod ollama_client;

pub use llm_id::LLMId;
pub mod diff_validation;
Expand Down
Loading