Skip to content

Commit 68c5106

Browse files
committed
refactor: Refactor OpenAI client initialization and error handling.
- Add support for TLS 1.2 in http_client
1 parent a54badf commit 68c5106

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/llms/openai.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{anyhow, bail, Ok, Result};
22

33
use async_trait::async_trait;
44

5-
use reqwest::Proxy;
5+
use reqwest::{tls, Proxy};
66
use tiktoken_rs::{get_chat_completion_max_tokens, get_completion_max_tokens};
77

88
use crate::settings::OpenAISettings;
@@ -39,7 +39,9 @@ impl OpenAIClient {
3939
let api_base = settings.api_base.unwrap_or_default();
4040
let mut http_client = reqwest::Client::builder().gzip(true).brotli(true);
4141
if api_base.is_empty() {
42-
http_client = http_client.http2_prior_knowledge();
42+
http_client = http_client
43+
.http2_prior_knowledge()
44+
.min_tls_version(tls::Version::TLS_1_2);
4345
} else {
4446
openai_client = openai_client.with_api_base(&api_base);
4547
}

0 commit comments

Comments
 (0)