From f3865c1742bab2ae3b9f128db46158724dbcf8f6 Mon Sep 17 00:00:00 2001 From: Holegots Date: Wed, 28 Jun 2023 00:05:19 +0800 Subject: [PATCH 1/7] 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/7] 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") == "" { From c056cb813c40c57c1af0c275f1f3e0a75b99ab4f Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 28 Jun 2023 17:10:02 +0800 Subject: [PATCH 3/7] set client, respect proxy --- go.mod | 2 +- go.sum | 2 ++ internal/chatgpt/request.go | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d919d13..5bd73b8 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/acheong08/OpenAIAuth v0.0.0-20230609193408-55a0f33f1057 github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd - github.com/acheong08/funcaptcha v0.2.1-0.20230626152808-543148a3c981 + github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8 github.com/bogdanfinn/fhttp v0.5.23 github.com/bogdanfinn/tls-client v1.4.0 github.com/gin-gonic/gin v1.9.1 diff --git a/go.sum b/go.sum index 2e16abe..bb488d6 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/acheong08/funcaptcha v0.2.1-0.20230626140502-adeab195a0b3 h1:3SiHkE69 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/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8 h1:COt2vPM8gz+PiUjeWH1enYPfMM3FiM/HFELqU6nO2PQ= +github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/bogdanfinn/fhttp v0.5.23 h1:4Xb5OjYArB8GpnUw4A4r5jmt8UW0/Cvey3R9nS2dC9U= diff --git a/internal/chatgpt/request.go b/internal/chatgpt/request.go index fc5e6fb..2cc4fd2 100644 --- a/internal/chatgpt/request.go +++ b/internal/chatgpt/request.go @@ -11,6 +11,7 @@ import ( "os" "strings" + arkose "github.com/acheong08/funcaptcha" http "github.com/bogdanfinn/fhttp" tls_client "github.com/bogdanfinn/tls-client" "github.com/gin-gonic/gin" @@ -60,6 +61,8 @@ func init() { proxies = append(proxies, proxy) } } + arkose.SetTLSClient(&client) + } func random_int(min int, max int) int { From 2f9913ba004031bad05ee5bdbe2e5ea7438a9365 Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 28 Jun 2023 17:14:01 +0800 Subject: [PATCH 4/7] go mod tidy --- go.mod | 2 +- go.sum | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6eb9624..92406d8 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/go-resty/resty/v2 v2.7.0 github.com/google/uuid v1.3.0 + github.com/joho/godotenv v1.5.1 github.com/tidwall/gjson v1.14.4 k8s.io/apimachinery v0.27.2 ) @@ -26,7 +27,6 @@ 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 4c6b785..9c23f39 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.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/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8 h1:COt2vPM8gz+PiUjeWH1enYPfMM3FiM/HFELqU6nO2PQ= github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= From 8e3a295a5c21ef9633bcf3345e0b667824fad75b Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 28 Jun 2023 17:15:07 +0800 Subject: [PATCH 5/7] delete useless line --- conversion/requests/chatgpt/convert.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/conversion/requests/chatgpt/convert.go b/conversion/requests/chatgpt/convert.go index c32ef7c..2c39b1a 100644 --- a/conversion/requests/chatgpt/convert.go +++ b/conversion/requests/chatgpt/convert.go @@ -23,10 +23,6 @@ func ConvertAPIRequest(api_request official_types.APIRequest) chatgpt_types.Chat } chatgpt_request.Model = api_request.Model } - if api_request.Model == "gpt-4" { - // Mobile was fixed in rate limiting. - chatgpt_request.Model = "gpt-4" - } if api_request.PluginIDs != nil { chatgpt_request.PluginIDs = api_request.PluginIDs chatgpt_request.Model = "gpt-4-plugins" From a67879ac54ab6ae5ea40c89fc59f3728a79b9cdd Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 28 Jun 2023 23:49:12 +0800 Subject: [PATCH 6/7] funcaptcha bump --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 92406d8..e17fd77 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/acheong08/OpenAIAuth v0.0.0-20230609193408-55a0f33f1057 github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd - github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8 + github.com/acheong08/funcaptcha v0.2.1-0.20230628154248-28b05efd8e52 github.com/bogdanfinn/fhttp v0.5.23 github.com/bogdanfinn/tls-client v1.4.0 github.com/gin-gonic/gin v1.9.1 diff --git a/go.sum b/go.sum index 9c23f39..c17cc68 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd h1:oIpfrRhD7Jus4 github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd/go.mod h1:0yO7neMeJLvKk/B/fq5votDY8rByrOPDubpvU+6saKo= github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8 h1:COt2vPM8gz+PiUjeWH1enYPfMM3FiM/HFELqU6nO2PQ= github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= +github.com/acheong08/funcaptcha v0.2.1-0.20230628154248-28b05efd8e52 h1:cZ9RUUz+A5HUXQjIf9KJzF+K90EEcVdSJyWJc8S7qds= +github.com/acheong08/funcaptcha v0.2.1-0.20230628154248-28b05efd8e52/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/bogdanfinn/fhttp v0.5.23 h1:4Xb5OjYArB8GpnUw4A4r5jmt8UW0/Cvey3R9nS2dC9U= From 6fa8d83f179134da1ceadc57d065af2455696c7e Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 29 Jun 2023 13:26:56 +0800 Subject: [PATCH 7/7] bump deps --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e17fd77..27a0094 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/acheong08/OpenAIAuth v0.0.0-20230609193408-55a0f33f1057 github.com/acheong08/endless v0.0.0-20230615162514-90545c7793fd - github.com/acheong08/funcaptcha v0.2.1-0.20230628154248-28b05efd8e52 + github.com/acheong08/funcaptcha v0.2.1-0.20230629044031-084e7dfaffef github.com/bogdanfinn/fhttp v0.5.23 github.com/bogdanfinn/tls-client v1.4.0 github.com/gin-gonic/gin v1.9.1 diff --git a/go.sum b/go.sum index c17cc68..e0e6719 100644 --- a/go.sum +++ b/go.sum @@ -6,6 +6,8 @@ github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8 h1:COt2vPM8 github.com/acheong08/funcaptcha v0.2.1-0.20230628085018-57a8c9b81bc8/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= github.com/acheong08/funcaptcha v0.2.1-0.20230628154248-28b05efd8e52 h1:cZ9RUUz+A5HUXQjIf9KJzF+K90EEcVdSJyWJc8S7qds= github.com/acheong08/funcaptcha v0.2.1-0.20230628154248-28b05efd8e52/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= +github.com/acheong08/funcaptcha v0.2.1-0.20230629044031-084e7dfaffef h1:B5fq4j+Qiu/6vay/70BG9mBuBgF28CnA4MTx1+J2V+o= +github.com/acheong08/funcaptcha v0.2.1-0.20230629044031-084e7dfaffef/go.mod h1:VupbjtVAODvgyAB3Zo86fOA53G+UAmaV/Rk9jUCGuTU= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/bogdanfinn/fhttp v0.5.23 h1:4Xb5OjYArB8GpnUw4A4r5jmt8UW0/Cvey3R9nS2dC9U=