From 66a73c7b84a9cffc67f1dc0b6b836b4d9e5d0c42 Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 16 Mar 2023 17:11:25 +0800 Subject: feat: add `config.connect_timeout` (#76) --- src/client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/client.rs') 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) -- cgit v1.2.3