From 2b22c0427d6c02977833a265a32701ee020a947f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Jul 2023 11:14:47 +0800 Subject: [PATCH] update renew schedule --- README.md | 6 ++++-- README_ZH.md | 2 +- conversion/requests/chatgpt/convert.go | 7 ++++--- main.go | 9 ++++++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 30ae569..56dc3ce 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ # ChatGPT-to-API -Create a fake API using ChatGPT's website [中文说明](https://github.com/xqdoo00o/ChatGPT-to-API/blob/master/README_ZH.md) +Create a fake API using ChatGPT's website > ## IMPORTANT > You will not get free support for this repository. This was made for my own personal use and documentation will continue to be limited as I don't really need documentation. You will find more detailed documentation in the Chinese docs by a contributor. **API endpoint: http://127.0.0.1:8080/v1/chat/completions.** +[中文文档(Chinese Docs)](https://github.com/xqdoo00o/ChatGPT-to-API/blob/master/README_ZH.md) ## Setup ### Authentication @@ -22,7 +23,7 @@ email:password All authenticated access tokens will store in `access_tokens.json` -Auto renew access tokens after 20 days +Auto renew access tokens after 14 days Caution! please use unblocked ip for authentication, first login to `https://chat.openai.com/` to check ip availability if you can. @@ -52,6 +53,7 @@ go build - `SERVER_HOST` - Set to 127.0.0.1 by default - `SERVER_PORT` - Set to 8080 by default - `OPENAI_EMAIL` and `OPENAI_PASSWORD` - It will automatically refresh your PUID if set (requires Plus account) + - `ENABLE_HISTORY` - Set to true by default ### Files (Optional) - `proxies.txt` - A list of proxies separated by new line diff --git a/README_ZH.md b/README_ZH.md index 328b2c0..f0eb6d6 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -20,7 +20,7 @@ 所有登录后的Access tokens会存放在`access_tokens.json` -每20天自动更新Access tokens +每14天自动更新Access tokens 注意! 请使用未封锁的ip登录账号,请先打开浏览器登录`https://chat.openai.com/`以检查ip是否可用 diff --git a/conversion/requests/chatgpt/convert.go b/conversion/requests/chatgpt/convert.go index 7ece96d..8bb97ac 100644 --- a/conversion/requests/chatgpt/convert.go +++ b/conversion/requests/chatgpt/convert.go @@ -21,9 +21,10 @@ func ConvertAPIRequest(api_request official_types.APIRequest) chatgpt_types.Chat } else { fmt.Println("Error getting Arkose token: ", err) } - chatgpt_request.Model = "gpt-4" - if api_request.Model == "gpt-4-browsing" || api_request.Model == "gpt-4-mobile" || api_request.Model == "gpt-4-code-interpreter" { - chatgpt_request.Model = api_request.Model + chatgpt_request.Model = api_request.Model + // Cover some models like gpt-4-32k + if len(api_request.Model) >= 7 && api_request.Model[6] >= 48 && api_request.Model[6] <= 57 { + chatgpt_request.Model = "gpt-4" } } if api_request.PluginIDs != nil { diff --git a/main.go b/main.go index 0cd3940..1007e54 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ var ACCESS_TOKENS tokens.AccessToken var proxies []string func checkProxy() { - // Check for proxies.txt + // first check for proxies.txt proxies = []string{} if _, err := os.Stat("proxies.txt"); err == nil { // Each line is a proxy, put in proxies array @@ -38,6 +38,13 @@ func checkProxy() { } } } + // if no proxies, then check env http_proxy + if len(proxies) == 0 { + proxy := os.Getenv("http_proxy") + if proxy != "" { + proxies = append(proxies, proxy) + } + } } func init() {