From f3865c1742bab2ae3b9f128db46158724dbcf8f6 Mon Sep 17 00:00:00 2001 From: Holegots Date: Wed, 28 Jun 2023 00:05:19 +0800 Subject: [PATCH 1/2] feat: support PORT env --- main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.go b/main.go index af33d64..d5c2181 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,9 @@ func init() { HOST = os.Getenv("SERVER_HOST") PORT = os.Getenv("SERVER_PORT") + if PORT == "" { + PORT = os.Getenv("PORT") + } if HOST == "" { HOST = "127.0.0.1" } From ce0e59e85330cc8d02b50889a73822775f86aee5 Mon Sep 17 00:00:00 2001 From: Holegots Date: Wed, 28 Jun 2023 11:58:54 +0800 Subject: [PATCH 2/2] feat: support PORT env feat: support dotenv fix: change gpt-4-mobile 2 gpt-4 --- .env.example | 3 +++ .gitignore | 1 + conversion/requests/chatgpt/convert.go | 3 ++- go.mod | 1 + go.sum | 4 ++-- main.go | 2 ++ 6 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..c15884f --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +ADMIN_PASSWORD= +OPENAI_EMAIL= +OPENAI_PASSWORD= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 36e2100..c7720d7 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ access_tokens.json freechatgpt chatgpttoapi tools/authenticator/.proxies.txt.swp +.env \ No newline at end of file diff --git a/conversion/requests/chatgpt/convert.go b/conversion/requests/chatgpt/convert.go index 0b2bde1..c32ef7c 100644 --- a/conversion/requests/chatgpt/convert.go +++ b/conversion/requests/chatgpt/convert.go @@ -24,7 +24,8 @@ func ConvertAPIRequest(api_request official_types.APIRequest) chatgpt_types.Chat chatgpt_request.Model = api_request.Model } if api_request.Model == "gpt-4" { - chatgpt_request.Model = "gpt-4-mobile" + // Mobile was fixed in rate limiting. + chatgpt_request.Model = "gpt-4" } if api_request.PluginIDs != nil { chatgpt_request.PluginIDs = api_request.PluginIDs diff --git a/go.mod b/go.mod index d919d13..6928e8b 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.14.1 // indirect github.com/goccy/go-json v0.10.2 // indirect + github.com/joho/godotenv v1.5.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.16.6 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect diff --git a/go.sum b/go.sum index 2e16abe..80807e5 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ github.com/acheong08/OpenAIAuth v0.0.0-20230609193408-55a0f33f1057 h1:AmqKpClFTU github.com/acheong08/OpenAIAuth v0.0.0-20230609193408-55a0f33f1057/go.mod h1:ES3Dh9hnbR2mDPlNTagj5e3b4nXECd4tbAjVgxggXEE= github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd h1:oIpfrRhD7Jus41dotbK+SQjWSFRnf1cLZUYCZpF/o/4= github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd/go.mod h1:0yO7neMeJLvKk/B/fq5votDY8rByrOPDubpvU+6saKo= -github.com/acheong08/funcaptcha v0.2.1-0.20230626140502-adeab195a0b3 h1:3SiHkE69H/JWT19fpIvjRScPDx5DnWnzzZpR5V4vHkQ= -github.com/acheong08/funcaptcha v0.2.1-0.20230626140502-adeab195a0b3/go.mod h1:fKxNB5i7g9h6QDTIY1YZamwFmMpAJK++wMYij5NuMm4= github.com/acheong08/funcaptcha v0.2.1-0.20230626152808-543148a3c981 h1:ibvQvXMdniYRTYJFDaUJvG+25BF/bQxzE3AfDtv+0Ag= github.com/acheong08/funcaptcha v0.2.1-0.20230626152808-543148a3c981/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= @@ -46,6 +44,8 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk= diff --git a/main.go b/main.go index d5c2181..3edc569 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "github.com/acheong08/OpenAIAuth/auth" "github.com/acheong08/endless" "github.com/gin-gonic/gin" + "github.com/joho/godotenv" ) var HOST string @@ -18,6 +19,7 @@ var PORT string var ACCESS_TOKENS tokens.AccessToken func init() { + _ = godotenv.Load(".env") go func() { for { if os.Getenv("OPENAI_EMAIL") == "" || os.Getenv("OPENAI_PASSWORD") == "" {