Skip to content

Commit

Permalink
Merge branch 'pr/22' into Add-Gemini
Browse files Browse the repository at this point in the history
  • Loading branch information
bi1101 committed May 10, 2024
2 parents e34333c + 2e3c136 commit 9e01a03
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 992 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ WORKDIR /tls
# Set the working directory
WORKDIR /app

# update CA certificates
RUN apk update && apk upgrade && apk add --no-cache ca-certificates
RUN update-ca-certificates

# Copy the Go Modules manifests (go.mod and go.sum files)
COPY go.mod go.sum ./

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ All authenticated access tokens and PUID will store in `access_tokens.json`

Auto renew access tokens and PUID after 1 day

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://chatgpt.com/` to check ip availability if you can.

### HAR file pool

Currently logged in account, using the GPT-4 model and most GPT-3.5 models, you need to configure a HAR file (file with .har suffix) to complete captcha verification.

1. Use a chromium-based browser (Chrome, Edge) to open the browser developer tools (F12), switch to the Network tab, and check the **preserve log** option.

2. Log in to `https://chat.openai.com/`, create a new chat and select the GPT-4 model, enter any text, switch to the GPT-3.5 model, and enter any text.
2. Log in to `https://chatgpt.com/`, create a new chat and select the GPT-4 model, enter any text, switch to the GPT-3.5 model, and enter any text.

3. Click the Export HAR button under the Network tab to export the file `chat.openai.com.har` and place it in the `harPool` folder of the same level as this program.
3. Click the Export HAR button under the Network tab to export the file `chatgpt.com.har` and place it in the `harPool` folder of the same level as this program.

### API Authentication (Optional)

Expand Down
52 changes: 0 additions & 52 deletions README_CN.md

This file was deleted.

2 changes: 1 addition & 1 deletion README_JA.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ email:password

アクセストークンは 7 日後に自動更新されます

注意!認証にはブロックされていない ip を使用してください。可能であれば、まず `https://chat.openai.com/` にログインして ip の可用性を確認してください。
注意!認証にはブロックされていない ip を使用してください。可能であれば、まず `https://chatgpt.com/` にログインして ip の可用性を確認してください。

### API認証(オプション)

Expand Down
6 changes: 3 additions & 3 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

每天自动更新Access tokens和PUID

注意! 请使用未封锁的ip登录账号,请先打开浏览器登录`https://chat.openai.com/`以检查ip是否可用
注意! 请使用未封锁的ip登录账号,请先打开浏览器登录`https://chatgpt.com/`以检查ip是否可用

### HAR文件池

当前登录账号,使用GPT-4模型以及大部分GPT-3.5模型,均需要配置HAR文件(.har后缀名的文件)以完成captcha验证。

1. 使用基于chromium的浏览器(Chrome,Edge)打开浏览器开发者工具(F12),并切换到网络标签页,勾选**保留日志**选项。

2. 登录`https://chat.openai.com/`,新建聊天并选择GPT-4模型,随意输入下文字,切换到GPT-3.5模型,随意输入下文字。
2. 登录`https://chatgpt.com/`,新建聊天并选择GPT-4模型,随意输入下文字,切换到GPT-3.5模型,随意输入下文字。

3. 点击网络标签页下的导出HAR按钮,导出文件`chat.openai.com.har`,放置到本程序同级的`harPool`文件夹里。
3. 点击网络标签页下的导出HAR按钮,导出文件`chatgpt.com.har`,放置到本程序同级的`harPool`文件夹里。

### API 密钥(可选)

Expand Down
1 change: 1 addition & 0 deletions conversion/requests/chatgpt/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func ConvertAPIRequest(api_request official_types.APIRequest, account string, se
val := api_request.Model[12:]
chatgpt_request.ConversationMode.Kind = "gizmo_interaction"
chatgpt_request.ConversationMode.GizmoId = val
chatgpt_request.Model = "text-davinci-002-render-sha"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/Docker_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
```

- 这里的ports,左边是外部端口,用于外部访问。右边的Docker端口,需要匹配下面程序设置的监听Port。
- 如果参数`API_REVERSE_PROXY`为空,则默认的请求URL为`https://chat.openai.com/backend-api/conversation`,并且需要提供PUID。PUID的获取参考 [README_CN.md](../README_CN.md)
- 如果参数`API_REVERSE_PROXY`为空,则默认的请求URL为`https://chatgpt.com/backend-api/conversation`,并且需要提供PUID。PUID的获取参考 [README_CN.md](../README_CN.md)
- 这个密码需要自定义,我们构建请求的时候需要它来鉴权。默认是```TotallySecurePassword```

2 changes: 1 addition & 1 deletion docs/TOKEN_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ http://ai.fakeopen.com/auth
你需要在这个新的网站的指导下安装浏览器插件,官方说明的有效期是14天。支持谷歌微软等第三方登录。(我谷歌注册的OpenAI就可以用这个)

## 官网获取 Token
https://chat.openai.com/api/auth/session
https://chatgpt.com/api/auth/session

打开后是个JSON,你需要先登录官方的ChatGPT网页版。里面有一个参数就是AccessToken。

Expand Down
16 changes: 7 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ require (
github.com/joho/godotenv v1.5.1
github.com/sashabaranov/go-openai v1.21.0
github.com/tidwall/gjson v1.17.1
github.com/xqdoo00o/OpenAIAuth v0.0.0-20240425072142-e599e4049d02
github.com/xqdoo00o/funcaptcha v0.0.0-20240403090732-1b604d808f6c
github.com/xqdoo00o/OpenAIAuth v0.0.0-20240507071909-7f24aae29d9e
github.com/xqdoo00o/funcaptcha v0.0.0-20240507071758-6c32cfc34bdc
github.com/zhu327/gemini-openai-proxy v0.0.0-20240328042054-d2c6c4cdff01
golang.org/x/crypto v0.22.0
golang.org/x/crypto v0.23.0
golang.org/x/image v0.15.0
golang.org/x/net v0.24.0
golang.org/x/net v0.25.0
google.golang.org/api v0.172.0
k8s.io/apimachinery v0.29.3
)
Expand Down Expand Up @@ -58,15 +58,13 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/quic-go/quic-go v0.43.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/quic-go/quic-go v0.43.1 // indirect
github.com/tam7t/hpkp v0.0.0-20160821193359-2b70b4024ed5 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
Expand All @@ -81,8 +79,8 @@ require (
golang.org/x/arch v0.7.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJ
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -146,8 +145,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/quic-go/quic-go v0.43.0 h1:sjtsTKWX0dsHpuMJvLxGqoQdtgJnbAPWY+W+5vjYW/g=
github.com/quic-go/quic-go v0.43.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M=
github.com/quic-go/quic-go v0.43.1 h1:fLiMNfQVe9q2JvSsiXo4fXOEguXHGGl9+6gLp4RPeZQ=
github.com/quic-go/quic-go v0.43.1/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/sashabaranov/go-openai v1.21.0 h1:isAf3zPSD3VLd0pC2/2Q6ZyRK7jzPAaz+X3rjsviaYQ=
Expand Down Expand Up @@ -177,10 +176,10 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/xqdoo00o/OpenAIAuth v0.0.0-20240425072142-e599e4049d02 h1:l+ADAnV1KDjZkY0ccAvVYzSCGbA90xitA1aP+7yR0Yc=
github.com/xqdoo00o/OpenAIAuth v0.0.0-20240425072142-e599e4049d02/go.mod h1:XHxG7wI3Erk4nS0rwjXVF3FllYW5QxsRynnJ0GqAMCQ=
github.com/xqdoo00o/funcaptcha v0.0.0-20240403090732-1b604d808f6c h1:nj17XsSTwprsZUDXLldOUZmqz7VlHsLCeXXFOE6Q+Mk=
github.com/xqdoo00o/funcaptcha v0.0.0-20240403090732-1b604d808f6c/go.mod h1:7aCyoW5MHDUsoooMVLqKe0F7W9HMPUvDG3bXqw++8XA=
github.com/xqdoo00o/OpenAIAuth v0.0.0-20240507071909-7f24aae29d9e h1:tNV/b3/N7+5vnweAjhYlnhuF2olmj0NxvFD03R3xudE=
github.com/xqdoo00o/OpenAIAuth v0.0.0-20240507071909-7f24aae29d9e/go.mod h1:TOXe2RBzDx5/w2RYzP7C1WNfNJx1wEVOSkCBcGSaNrM=
github.com/xqdoo00o/funcaptcha v0.0.0-20240507071758-6c32cfc34bdc h1:GA82q8G/mh5LLaBAo3UWw4zvxk/BlarGSuonyK4tz3Y=
github.com/xqdoo00o/funcaptcha v0.0.0-20240507071758-6c32cfc34bdc/go.mod h1:MmsYdzgYjO6NQYNS8vtecBWUFWwD4TApVzMp8iwKiR0=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zhu327/gemini-openai-proxy v0.0.0-20240328042054-d2c6c4cdff01 h1:oTKr6NUPO0Q/8eUPf75hpZrUYfP8eQLHdVbLTWVuf/c=
github.com/zhu327/gemini-openai-proxy v0.0.0-20240328042054-d2c6c4cdff01/go.mod h1:np6NnsU7xC3JTdGlOAOvWSudER6P43EnDhEvYrEL1Vc=
Expand All @@ -204,8 +203,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
Expand All @@ -228,8 +227,8 @@ golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.19.0 h1:9+E/EZBCbTLNrbN35fHv/a/d/mOBatymz1zbtQrXpIg=
golang.org/x/oauth2 v0.19.0/go.mod h1:vYi7skDa1x015PmRRYZ7+s1cWyPgrPiSYRe4rnsexc8=
Expand All @@ -254,8 +253,8 @@ golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
Expand All @@ -268,8 +267,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
2 changes: 1 addition & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func nightmare(c *gin.Context) {
for i := 3; i > 0; i-- {
var continue_info *chatgpt.ContinueInfo
var response_part string
response_part, continue_info = chatgpt.Handler(c, response, &secret, proxy_url, deviceId, uid, translated_request, original_request.Stream)
response_part, continue_info = chatgpt.Handler(c, response, &secret, proxy_url, deviceId, uid, original_request.Stream)
full_response += response_part
if continue_info == nil {
break
Expand Down
Loading

0 comments on commit 9e01a03

Please sign in to comment.