diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-16 17:11:25 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-16 17:11:25 +0800 |
| commit | 66a73c7b84a9cffc67f1dc0b6b836b4d9e5d0c42 (patch) | |
| tree | 79da3a6fc3b737031d84505a91655695b146cf5f /src/config | |
| parent | 1ef97b2f32caecdb2eef9fe3755390f36d96eae5 (diff) | |
| download | aichat-66a73c7b84a9cffc67f1dc0b6b836b4d9e5d0c42.tar.gz | |
feat: add `config.connect_timeout` (#76)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index f543ee9..1607711 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -12,6 +12,7 @@ use anyhow::{anyhow, bail, Context, Result}; use inquire::{Confirm, Text}; use parking_lot::RwLock; use serde::Deserialize; +use std::time::Duration; use std::{ env, fs::{create_dir_all, read_to_string, File, OpenOptions}, @@ -65,6 +66,8 @@ pub struct Config { pub conversation_first: bool, /// Is ligth theme pub light_theme: bool, + /// Set a timeout in seconds for connect to gpt + pub connect_timeout: usize, /// Predefined roles #[serde(skip)] pub roles: Vec<Role>, @@ -90,6 +93,7 @@ impl Default for Config { dry_run: false, conversation_first: false, light_theme: false, + connect_timeout: 10, roles: vec![], role: None, conversation: None, @@ -267,6 +271,10 @@ impl Config { } } + pub fn get_connect_timeout(&self) -> Duration { + Duration::from_secs(self.connect_timeout as u64) + } + pub fn get_model(&self) -> (String, usize) { self.model.clone() } @@ -328,6 +336,7 @@ impl Config { ("proxy", proxy), ("conversation_first", self.conversation_first.to_string()), ("light_theme", self.light_theme.to_string()), + ("connect_timeout", self.connect_timeout.to_string()), ("dry_run", self.dry_run.to_string()), ]; let mut output = String::new(); |
