summaryrefslogtreecommitdiffstats
path: root/src/client.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-16 17:11:25 +0800
committerGitHub <noreply@github.com>2023-03-16 17:11:25 +0800
commit66a73c7b84a9cffc67f1dc0b6b836b4d9e5d0c42 (patch)
tree79da3a6fc3b737031d84505a91655695b146cf5f /src/client.rs
parent1ef97b2f32caecdb2eef9fe3755390f36d96eae5 (diff)
downloadaichat-66a73c7b84a9cffc67f1dc0b6b836b4d9e5d0c42.tar.gz
feat: add `config.connect_timeout` (#76)
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/client.rs b/src/client.rs
index b438440..14d65d0 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -10,7 +10,6 @@ use std::time::Duration;
use tokio::runtime::Runtime;
use tokio::time::sleep;
-const CONNECT_TIMEOUT: Duration = Duration::from_secs(10);
const API_URL: &str = "https://api.openai.com/v1/chat/completions";
#[derive(Debug)]
@@ -128,8 +127,9 @@ impl ChatGptClient {
builder = builder
.proxy(Proxy::all(proxy).with_context(|| format!("Invalid proxy `{proxy}`"))?);
}
+ let timeout = self.config.read().get_connect_timeout();
let client = builder
- .connect_timeout(CONNECT_TIMEOUT)
+ .connect_timeout(timeout)
.build()
.with_context(|| "Failed to build http client")?;
Ok(client)