1
0

update renew schedule

This commit is contained in:
root 2023-07-20 11:14:47 +08:00
parent cacfa46571
commit 2b22c0427d
4 changed files with 17 additions and 7 deletions

View File

@ -1,11 +1,12 @@
# ChatGPT-to-API # 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 > ## 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. > 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.** **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 ## Setup
### Authentication ### Authentication
@ -22,7 +23,7 @@ email:password
All authenticated access tokens will store in `access_tokens.json` 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. 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_HOST` - Set to 127.0.0.1 by default
- `SERVER_PORT` - Set to 8080 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) - `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) ### Files (Optional)
- `proxies.txt` - A list of proxies separated by new line - `proxies.txt` - A list of proxies separated by new line

View File

@ -20,7 +20,7 @@
所有登录后的Access tokens会存放在`access_tokens.json` 所有登录后的Access tokens会存放在`access_tokens.json`
20天自动更新Access tokens 14天自动更新Access tokens
注意! 请使用未封锁的ip登录账号请先打开浏览器登录`https://chat.openai.com/`以检查ip是否可用 注意! 请使用未封锁的ip登录账号请先打开浏览器登录`https://chat.openai.com/`以检查ip是否可用

View File

@ -21,9 +21,10 @@ func ConvertAPIRequest(api_request official_types.APIRequest) chatgpt_types.Chat
} else { } else {
fmt.Println("Error getting Arkose token: ", err) fmt.Println("Error getting Arkose token: ", err)
} }
chatgpt_request.Model = "gpt-4" chatgpt_request.Model = api_request.Model
if api_request.Model == "gpt-4-browsing" || api_request.Model == "gpt-4-mobile" || api_request.Model == "gpt-4-code-interpreter" { // Cover some models like gpt-4-32k
chatgpt_request.Model = api_request.Model 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 { if api_request.PluginIDs != nil {

View File

@ -20,7 +20,7 @@ var ACCESS_TOKENS tokens.AccessToken
var proxies []string var proxies []string
func checkProxy() { func checkProxy() {
// Check for proxies.txt // first check for proxies.txt
proxies = []string{} proxies = []string{}
if _, err := os.Stat("proxies.txt"); err == nil { if _, err := os.Stat("proxies.txt"); err == nil {
// Each line is a proxy, put in proxies array // 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() { func init() {