Skip to content

Commit d04175a

Browse files
committed
use once_cell for more compat
1 parent 2b56e2c commit d04175a

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ serde-double-tag = "0.0.4"
2828
log = "0.4"
2929
strum = { version = "0.26", features = ["derive"] }
3030
strum_macros = "0.26"
31+
once_cell = "1.20"
3132

3233
[dev-dependencies]
3334
dotenvy = "0.15.7"

src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
use once_cell::sync::Lazy;
12
use reqwest::multipart::Form;
23
use reqwest::{header::AUTHORIZATION, Client, Method, RequestBuilder, Response};
34
use reqwest_eventsource::{CannotCloneRequestError, EventSource, RequestBuilderExt};
45
use serde::{de::DeserializeOwned, Deserialize, Serialize};
56
use std::env;
67
use std::env::VarError;
7-
use std::sync::{LazyLock, RwLock};
8+
use std::sync::RwLock;
89

910
pub mod assistants;
1011
pub mod chat;
@@ -16,10 +17,10 @@ pub mod files;
1617
pub mod models;
1718
pub mod moderations;
1819

19-
pub static DEFAULT_BASE_URL: LazyLock<String> =
20-
LazyLock::new(|| String::from("https://api.openai.com/v1/"));
21-
static DEFAULT_CREDENTIALS: LazyLock<RwLock<Credentials>> =
22-
LazyLock::new(|| RwLock::new(Credentials::from_env()));
20+
pub static DEFAULT_BASE_URL: Lazy<String> =
21+
Lazy::new(|| String::from("https://api.openai.com/v1/"));
22+
static DEFAULT_CREDENTIALS: Lazy<RwLock<Credentials>> =
23+
Lazy::new(|| RwLock::new(Credentials::from_env()));
2324

2425
/// Holds the API key and base URL for an OpenAI-compatible API.
2526
#[derive(Debug, Clone, Eq, PartialEq)]

0 commit comments

Comments
 (0)