mirror of
https://github.com/sigoden/aichat
synced 2024-11-16 06:15:26 +00:00
refactor: aware of lowercase https_proxy/all_proxy (#484)
This commit is contained in:
parent
1ff0553c2f
commit
82a9ef024d
@ -38,8 +38,8 @@ clients:
|
||||
# extra_fields: # Set custom parameters, will merge with the body json
|
||||
# key: value
|
||||
# extra:
|
||||
# proxy: socks5://127.0.0.1:1080 # Specify https/socks5 proxy server. ENV: HTTPS_PROXY/ALL_PROXY
|
||||
# connect_timeout: 10 # Set a timeout in seconds for connect to server
|
||||
# proxy: socks5://127.0.0.1:1080 # Set https/socks5 proxy. ENV: HTTPS_PROXY/https_proxy/ALL_PROXY/all_proxy
|
||||
# connect_timeout: 10 # Set timeout in seconds for connect to api
|
||||
|
||||
# See https://platform.openai.com/docs/quickstart
|
||||
- type: openai
|
||||
|
@ -693,11 +693,14 @@ fn to_json(kind: &PromptKind, value: &str) -> Value {
|
||||
|
||||
fn set_proxy(builder: ClientBuilder, proxy: &Option<String>) -> Result<ClientBuilder> {
|
||||
let proxy = if let Some(proxy) = proxy {
|
||||
if proxy.is_empty() || proxy == "false" || proxy == "-" {
|
||||
if proxy.is_empty() || proxy == "-" {
|
||||
return Ok(builder);
|
||||
}
|
||||
proxy.clone()
|
||||
} else if let Ok(proxy) = env::var("HTTPS_PROXY").or_else(|_| env::var("ALL_PROXY")) {
|
||||
} else if let Some(proxy) = ["HTTPS_PROXY", "https_proxy", "ALL_PROXY", "all_proxy"]
|
||||
.into_iter()
|
||||
.find_map(|v| env::var(v).ok())
|
||||
{
|
||||
proxy
|
||||
} else {
|
||||
return Ok(builder);
|
||||
|
Loading…
Reference in New Issue
Block a user