mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-29 14:43:55 +03:00
Use the OPENAI_API_KEY
environment variable when present
This commit is contained in:
parent
31a70efe66
commit
f904698457
@ -26,7 +26,7 @@ use language::{language_settings::SoftWrap, Buffer, LanguageRegistry, ToOffset a
|
||||
use serde::Deserialize;
|
||||
use settings::SettingsStore;
|
||||
use std::{
|
||||
borrow::Cow, cell::RefCell, cmp, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc,
|
||||
borrow::Cow, cell::RefCell, cmp, env, fmt::Write, io, iter, ops::Range, path::PathBuf, rc::Rc,
|
||||
sync::Arc, time::Duration,
|
||||
};
|
||||
use util::{
|
||||
@ -393,7 +393,9 @@ impl Panel for AssistantPanel {
|
||||
if active {
|
||||
if self.api_key.borrow().is_none() && !self.has_read_credentials {
|
||||
self.has_read_credentials = true;
|
||||
let api_key = if let Some((_, api_key)) = cx
|
||||
let api_key = if let Ok(api_key) = env::var("OPENAI_API_KEY") {
|
||||
Some(api_key)
|
||||
} else if let Some((_, api_key)) = cx
|
||||
.platform()
|
||||
.read_credentials(OPENAI_API_URL)
|
||||
.log_err()
|
||||
|
Loading…
Reference in New Issue
Block a user