mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
6ba7fc0317
* chore: create trait * test: add tests * chore: remove log * chore: disable log
17 lines
353 B
Rust
17 lines
353 B
Rust
use anyhow::{anyhow, Error};
|
|
|
|
pub struct OpenAISetting {
|
|
pub openai_api_key: String,
|
|
}
|
|
|
|
const OPENAI_API_KEY: &str = "OPENAI_API_KEY";
|
|
|
|
impl OpenAISetting {
|
|
pub fn from_env() -> Result<Self, Error> {
|
|
let openai_api_key =
|
|
std::env::var(OPENAI_API_KEY).map_err(|_| anyhow!("Missing OPENAI_API_KEY"))?;
|
|
|
|
Ok(Self { openai_api_key })
|
|
}
|
|
}
|