From 3f20635ff008ff412ed983918fa1201cccfdb908 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 18 Dec 2025 20:10:34 -0500 Subject: [PATCH] Restore google.rs to origin/main, modulo a comment --- crates/language_models/src/provider/google.rs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/crates/language_models/src/provider/google.rs b/crates/language_models/src/provider/google.rs index b29391abce08eca657cbede66049264e7508eef2..09380bac0c2537bc9d92626fe7b9cac8f9856105 100644 --- a/crates/language_models/src/provider/google.rs +++ b/crates/language_models/src/provider/google.rs @@ -1,5 +1,6 @@ use anyhow::{Context as _, Result, anyhow}; use collections::BTreeMap; +use credentials_provider::CredentialsProvider; use futures::{FutureExt, Stream, StreamExt, future, future::BoxFuture}; use google_ai::{ FunctionDeclaration, GenerateContentResponse, GoogleModelMode, Part, SystemInstruction, @@ -31,7 +32,7 @@ use ui::{ButtonLink, ConfiguredApiCard, List, ListBulletItem, prelude::*}; use ui_input::InputField; use util::ResultExt; -use language_model::ApiKeyState; +use language_model::{ApiKey, ApiKeyState}; const PROVIDER_ID: LanguageModelProviderId = language_model::GOOGLE_PROVIDER_ID; const PROVIDER_NAME: LanguageModelProviderName = language_model::GOOGLE_PROVIDER_NAME; @@ -116,6 +117,22 @@ impl GoogleLanguageModelProvider { }) } + pub fn api_key_for_gemini_cli(cx: &mut App) -> Task> { + if let Some(key) = API_KEY_ENV_VAR.value.clone() { + return Task::ready(Ok(key)); + } + let credentials_provider = ::global(cx); + let api_url = Self::api_url(cx).to_string(); + cx.spawn(async move |cx| { + Ok( + ApiKey::load_from_system_keychain(&api_url, credentials_provider.as_ref(), cx) + .await? + .key() + .to_string(), + ) + }) + } + fn settings(cx: &App) -> &GoogleSettings { &crate::AllLanguageModelSettings::get_global(cx).google } @@ -841,7 +858,6 @@ impl Render for ConfigurationView { .on_action(cx.listener(Self::save_api_key)) .child(Label::new(format!("To use {}, you need to add an API key. Follow these steps:", match &self.target_agent { ConfigurationViewTargetAgent::ZedAgent => "Zed's agent with Google AI".into(), - ConfigurationViewTargetAgent::EditPrediction => "Google AI for edit predictions".into(), ConfigurationViewTargetAgent::Other(agent) => agent.clone(), }))) .child(