acp: Handle Gemini Auth Better (#36631)
Release Notes: - N/A --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
parent
c9c708ff08
commit
5120b6b7f9
3 changed files with 195 additions and 19 deletions
|
@ -5,6 +5,7 @@ use crate::{AgentServer, AgentServerCommand};
|
|||
use acp_thread::{AgentConnection, LoadError};
|
||||
use anyhow::Result;
|
||||
use gpui::{Entity, Task};
|
||||
use language_models::provider::google::GoogleLanguageModelProvider;
|
||||
use project::Project;
|
||||
use settings::SettingsStore;
|
||||
use ui::App;
|
||||
|
@ -47,7 +48,7 @@ impl AgentServer for Gemini {
|
|||
settings.get::<AllAgentServersSettings>(None).gemini.clone()
|
||||
})?;
|
||||
|
||||
let Some(command) =
|
||||
let Some(mut command) =
|
||||
AgentServerCommand::resolve("gemini", &[ACP_ARG], None, settings, &project, cx).await
|
||||
else {
|
||||
return Err(LoadError::NotInstalled {
|
||||
|
@ -57,6 +58,10 @@ impl AgentServer for Gemini {
|
|||
}.into());
|
||||
};
|
||||
|
||||
if let Some(api_key)= cx.update(GoogleLanguageModelProvider::api_key)?.await.ok() {
|
||||
command.env.get_or_insert_default().insert("GEMINI_API_KEY".to_owned(), api_key.key);
|
||||
}
|
||||
|
||||
let result = crate::acp::connect(server_name, command.clone(), &root_dir, cx).await;
|
||||
if result.is_err() {
|
||||
let version_fut = util::command::new_smol_command(&command.path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue