AppFlowy/frontend/rust-lib/flowy-ai/src/config.rs
Nathan.fooo 6ba7fc0317
feat: openai and stabilityai integration (#3439)
* chore: create trait

* test: add tests

* chore: remove log

* chore: disable log
2023-09-21 12:41:52 +08:00

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 })
}
}