Giter VIP home page Giter VIP logo

chatgpt-to-api's Introduction

ChatGPT-to-API

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)

Setup

Authentication

Access token and PUID(only for PLUS account) retrieval has been automated by OpenAIAuth with account email & password.

accounts.txt - A list of accounts separated by new line

Format:

email:password
...

All authenticated access tokens and PUID will store in access_tokens.json

Auto renew access tokens and PUID after 7 days

Caution! please use unblocked ip for authentication, first login to https://chat.openai.com/ to check ip availability if you can.

GPT-4 Model (Optional)

If you configured a PLUS account and use the GPT-4 model, a HAR file (chat.openai.com.har) is required to complete CAPTCHA verification

  1. Use a chromium-based browser (Chrome, Edge) or Safari to login to https://chat.openai.com/, then open the browser developer tools (F12), and switch to the Network tab.

  2. Create a new chat and select the GPT-4 model, ask a question at will, click the Export HAR button under the Network tab, export the file chat.openai.com.har

API Authentication (Optional)

Custom API keys for this fake API, just like OpenAI api

api_keys.txt - A list of API keys separated by new line

Format:

sk-123456
88888888
...

Getting set up

git clone https://github.com/acheong08/ChatGPT-to-API
cd ChatGPT-to-API
go build
./freechatgpt

Environment variables

  • PUID - A cookie found on chat.openai.com for Plus users. This gets around Cloudflare rate limits
  • SERVER_HOST - Set to 127.0.0.1 by default
  • SERVER_PORT - Set to 8080 by default
  • ENABLE_HISTORY - Set to true by default

Files (Optional)

  • proxies.txt - A list of proxies separated by new line

    http://127.0.0.1:8888
    ...
    
  • access_tokens.json - A JSON array of access tokens for cycling (Alternatively, send a PATCH request to the correct endpoint)

    [{token:"access_token1", puid:"puid1"}, {token:"access_token2", puid:"puid2"}...]
    

Admin API docs

https://github.com/acheong08/ChatGPT-to-API/blob/master/docs/admin.md

API usage docs

https://platform.openai.com/docs/api-reference/chat

chatgpt-to-api's People

Contributors

blueskyxn avatar eltociear avatar fuergaosi233 avatar jjkoh95 avatar maxwellmai avatar oldweipro avatar pa733 avatar ryaochengfeng avatar supremetechwizard avatar xqdoo00o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatgpt-to-api's Issues

ERROR 413

Jun 18 03:15:52 PM [GIN] 2023/06/18 - 12:15:52 | 413 | 433.574605ms | 54.187.200.255 | POST "/v1/chat/completions"

error 500, unknown error encountered

hi @acheong08, i run golang program with latest source code, ping pong is fine. i dun use http_proxy and my API_REVERSE_PROXY is https://bypass.churchless.tech/api/conversation.

my revChatGPT is running fine, but it just not working by using ChatGPT-to-API.

$ curl http://127.0.0.1:8080/v1/chat/completions -d '{"model": "gpt-3.5-turbo","messages": [{"role": "user", "content": "Hello!"}]}'

{"error":{"code":"500","details":"","message":"Unknown error","param":null,"type":"internal_server_error"}}

i further go internal/chatgpt/request.go and print response variable, this is the output i capture

&{404 Not Found 404 HTTP/2.0 2 0 map[Alt-Svc:[h3=":443"; ma=86400] Cf-Cache-Status:[DYNAMIC] Cf-Ray:[7d374f803bef3de4-SIN] Content-Length:[4] Content-Type:[application/octet-stream] Date:[Wed, 07 Jun 2023 07:51:33 GMT] Nel:[{"success_fraction":0,"report_to":"cf-nel","max_age":604800}] Report-To:[{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=Ls8nN%2F9TcIBebnPyDaSSPEi3Hq8o6FQ5G%2FNJSQBr3zN2W3VEL6IRPmyk0ArpTepmUJwxrW5o4lrg0Wlbr4ULJq8TL5jqyiiWpF56sRQur%2FADEQhe8lSqS8zkAfqI9F6DmWlK5Dr%2B1xNZ"}],"group":"cf-nel","max_age":604800}] Server:[cloudflare]] 0xc00078a920 -1 [] false true map[] 0xc0002be400 0xc00079c4e0}

any idea to this problem?

no response a while then error 500

Jun 4 10:03:52 AM 2023/06/04 07:03:52 [Recovery] 2023/06/04 - 07:03:52 panic recovered:
Jun 4 10:03:52 AM POST /v1/chat/completions HTTP/1.1
Jun 4 10:03:52 AM [GIN] 2023/06/04 - 07:03:52 | 500 | 4m20s | 100.20.92.101 | POST "/v1/chat/completions"
Jun 4 10:03:52 AM Host: chathpt-to-api.onrender.com
Jun 4 10:03:52 AM Accept: /
Jun 4 10:03:52 AM Accept-Encoding: gzip
Jun 4 10:03:52 AM Cdn-Loop: cloudflare; subreqs=1
Jun 4 10:03:52 AM Cf-Connecting-Ip: 100.20.92.101
Jun 4 10:03:52 AM Cf-Ew-Via: 15
Jun 4 10:03:52 AM Cf-Ipcountry: US
Jun 4 10:03:52 AM Cf-Ray: 7d1e4b2b2156c3df-SEA
Jun 4 10:03:52 AM Cf-Visitor: {"scheme":"https"}
Jun 4 10:03:52 AM Cf-Worker: onrender.com
Jun 4 10:03:52 AM Content-Length: 1830
Jun 4 10:03:52 AM Content-Type: application/json
Jun 4 10:03:52 AM Render-Proxy-Ttl: 4
Jun 4 10:03:52 AM True-Client-Ip: 100.20.92.101
Jun 4 10:03:52 AM User-Agent: python-requests/2.31.0
Jun 4 10:03:52 AM X-Forwarded-For: 100.20.92.101, 172.71.151.78, 10.220.140.9
Jun 4 10:03:52 AM X-Forwarded-Proto: https
Jun 4 10:03:52 AM X-Request-Start: 1685861971737656
Jun 4 10:03:52 AM
Jun 4 10:03:52 AM
Jun 4 10:03:52 AM runtime error: invalid memory address or nil pointer dereference
Jun 4 10:03:52 AM /usr/local/go/src/runtime/panic.go:260 (0x44b0dc)
Jun 4 10:03:52 AM /usr/local/go/src/runtime/signal_unix.go:837 (0x44b0ac)
Jun 4 10:03:52 AM /app/handlers.go:107 (0x8c62d5)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8c7af5)
Jun 4 10:03:52 AM /app/middleware.go:57 (0x8c7a4e)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8c77d7)
Jun 4 10:03:52 AM /app/middleware.go:34 (0x8c77be)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8b0a01)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:102 (0x8b09ec)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8afb26)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:240 (0x8afb09)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8aebaa)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:620 (0x8ae831)
Jun 4 10:03:52 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:576 (0x8ae4dc)
Jun 4 10:03:52 AM /usr/local/go/src/net/http/server.go:2936 (0x66a275)
Jun 4 10:03:52 AM /usr/local/go/src/net/http/server.go:1995 (0x666af1)
Jun 4 10:03:52 AM /usr/local/go/src/runtime/asm_amd64.s:1598 (0x467580)
Jun 4 10:03:52 AM
Jun 4 10:07:21 AM
Jun 4 10:07:21 AM [GIN] 2023/06/04 - 07:07:21 | 500 | 4m21s | 41.77.19.29 | POST "/v1/chat/completions"
Jun 4 10:07:21 AM
Jun 4 10:07:21 AM 2023/06/04 07:07:21 [Recovery] 2023/06/04 - 07:07:21 panic recovered:
Jun 4 10:07:21 AM POST /v1/chat/completions HTTP/1.1
Jun 4 10:07:21 AM Host: chathpt-to-api.onrender.com
Jun 4 10:07:21 AM Accept: /
Jun 4 10:07:21 AM Accept-Encoding: gzip
Jun 4 10:07:21 AM Cdn-Loop: cloudflare; subreqs=1
Jun 4 10:07:21 AM Cf-Connecting-Ip: 41.77.19.29
Jun 4 10:07:21 AM Cf-Ew-Via: 15
Jun 4 10:07:21 AM Cf-Ipcountry: MG
Jun 4 10:07:21 AM Cf-Ray: 7d1e503c81b24fbd-JNB
Jun 4 10:07:21 AM Cf-Visitor: {"scheme":"https"}
Jun 4 10:07:21 AM Cf-Worker: onrender.com
Jun 4 10:07:21 AM Content-Length: 117
Jun 4 10:07:21 AM Content-Type: application/json
Jun 4 10:07:21 AM Render-Proxy-Ttl: 4
Jun 4 10:07:21 AM True-Client-Ip: 41.77.19.29
Jun 4 10:07:21 AM User-Agent: curl/7.88.1
Jun 4 10:07:21 AM X-Forwarded-For: 41.77.19.29, 197.234.243.29, 10.220.86.174
Jun 4 10:07:21 AM X-Forwarded-Proto: https
Jun 4 10:07:21 AM X-Request-Start: 1685862180122486
Jun 4 10:07:21 AM
Jun 4 10:07:21 AM
Jun 4 10:07:21 AM runtime error: invalid memory address or nil pointer dereference
Jun 4 10:07:21 AM /usr/local/go/src/runtime/panic.go:260 (0x44b0dc)
Jun 4 10:07:21 AM /usr/local/go/src/runtime/signal_unix.go:837 (0x44b0ac)
Jun 4 10:07:21 AM /app/handlers.go:107 (0x8c62d5)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8c7af5)
Jun 4 10:07:21 AM /app/middleware.go:57 (0x8c7a4e)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8c77d7)
Jun 4 10:07:21 AM /app/middleware.go:34 (0x8c77be)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8b0a01)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:102 (0x8b09ec)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8afb26)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/logger.go:240 (0x8afb09)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:174 (0x8aebaa)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:620 (0x8ae831)
Jun 4 10:07:21 AM /go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:576 (0x8ae4dc)
Jun 4 10:07:21 AM /usr/local/go/src/net/http/server.go:2936 (0x66a275)
Jun 4 10:07:21 AM /usr/local/go/src/net/http/server.go:1995 (0x666af1)
Jun 4 10:07:21 AM /usr/local/go/src/runtime/asm_amd64.s:1598 (0x467580)

ERR_EMPTY_RESPONSE

I'm posting it because I can't solve it.
I didn't know how to use authenticator due to how to insert proxies.txt, so i insert acces_tokens.json manually
[docker-compose-yml] is default
[Dockerfile] is default
[OS] Windows11

PS D:\ChatGPT-proxy\ChatGPT-to-API> docker logs chatgpttoapi
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.

  • using env: export GIN_MODE=release
  • using code: gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET /ping --> main.main.func1 (4 handlers)
[GIN-debug] PATCH /admin/puid --> main.puidHandler (5 handlers)
[GIN-debug] PATCH /admin/password --> main.passwordHandler (5 handlers)
[GIN-debug] PATCH /admin/tokens --> main.tokensHandler (6 handlers)
[GIN-debug] OPTIONS /v1/chat/completions --> main.optionsHandler (4 handlers)
[GIN-debug] POST /v1/chat/completions --> main.nightmare (4 handlers)
2023/04/25 04:33:21 1 127.0.0.1:8080

PS D:\ChatGPT-proxy\ChatGPT-to-API> docker inspect chatgpttoapi
[
{
"Id": "ec1065a50a4c98bf1222cc944a24cf2b09be7a6ba3b787d09c0c204dcc08f547",
"Created": "2023-04-25T04:33:20.603260485Z",
"Path": "./ChatGPT-To-API",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 19656,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-04-25T04:33:21.059680436Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:4da18b68d6e7259a67f3c33960c1a2033935a96b24c20e67f6499de158dff7af",
"ResolvConfPath": "/var/lib/docker/containers/ec1065a50a4c98bf1222cc944a24cf2b09be7a6ba3b787d09c0c204dcc08f547/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/ec1065a50a4c98bf1222cc944a24cf2b09be7a6ba3b787d09c0c204dcc08f547/hostname",
"HostsPath": "/var/lib/docker/containers/ec1065a50a4c98bf1222cc944a24cf2b09be7a6ba3b787d09c0c204dcc08f547/hosts",
"LogPath": "/var/lib/docker/containers/ec1065a50a4c98bf1222cc944a24cf2b09be7a6ba3b787d09c0c204dcc08f547/ec1065a50a4c98bf1222cc944a24cf2b09be7a6ba3b787d09c0c204dcc08f547-json.log",
"Name": "/chatgpttoapi",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"CgroupnsMode": "host",
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
27,
120
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/2aceeab341dea9e67687171a6c9d1f73cb52765614c1b74636bd91ea2a5e7aab-init/diff:/var/lib/docker/overlay2/w3aiwqctn2wjhabqfhbh922ba/diff:/var/lib/docker/overlay2/onklsdxdkoh11tke7kca0s0bl/diff",
"MergedDir": "/var/lib/docker/overlay2/2aceeab341dea9e67687171a6c9d1f73cb52765614c1b74636bd91ea2a5e7aab/merged",
"UpperDir": "/var/lib/docker/overlay2/2aceeab341dea9e67687171a6c9d1f73cb52765614c1b74636bd91ea2a5e7aab/diff",
"WorkDir": "/var/lib/docker/overlay2/2aceeab341dea9e67687171a6c9d1f73cb52765614c1b74636bd91ea2a5e7aab/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "ec1065a50a4c",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"./ChatGPT-To-API"
],
"Image": "chatgpt-to-api",
"Volumes": null,
"WorkingDir": "/app",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "be152ea2ca354fb6752ecf0af4c9ff98e6832f50a5e59da8a7fe90f777acf0f5",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/be152ea2ca35",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "8b22d2cb097cf13cbdb83df6a0f4fee1dca16e7d4c595448a1e738b88e38bc37",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "bead5a5db15ba990f9ec3ff9df6c54b4bf8def4925c7a49fd5657174a0a332e9",
"EndpointID": "8b22d2cb097cf13cbdb83df6a0f4fee1dca16e7d4c595448a1e738b88e38bc37",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]

PS D:\ChatGPT-proxy\ChatGPT-to-API> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f5d30e7d2f50 chatgpt-to-api "./ChatGPT-To-API" 2 minutes ago Up 2 minutes 127.0.0.1:8080->8080/tcp chatgpttoapi

[Feature Request] Support for /v1/completions API

I would like to request the addition of support for the /v1/completions API in the current project. Many other software applications already utilize this API, and it has become a common standard. However, the absence of support for this API in our project hinders its seamless integration with other software that relies on it.

By incorporating support for the /v1/completions API, our project would be able to effectively replace other software applications that use this API. This enhancement would provide a more comprehensive and cohesive user experience, enabling users to seamlessly transition between different software solutions.

add plugin api

model support gpt-4-plugins, but plugin_ids can't pass to openai.

Requesting for a Detailed Guide To Setup This

Hello
I am reaching out to request a detailed guide on how to install and set up this. I tried to deploy this on Railway. The deployment was success but not figuring out what to do next.

image

As a Newbie, Please provide me some steps on what to do next and how setup the access token. (POV: I never tried Go before)

Thank You

Streaming did not end with [DONE] & [ALL DONE] + finish reason is not "stop"

Hi thankyou for the project. I want to report some errors which make it unlike the officials api and, make it unsuable for streaming response when streaming set to "true"

I have attached the screenshot of the official response and the modded response for reference. Hop to here from you soon!
Official
image
from the modded API
image

[ERR]api code 500

I've set the ACCESS_TOKENS and PUID right, but when I'm trying to connect the api, retruns code 500:

[GIN] 2023/06/15 - 15:32:37 | 500 |  205.402537ms |       127.0.0.1 | POST     "/v1/chat/completions"

It was working when I was using 0.2.x ver of c-t-a and also 0.3.x, and someday how it started returning 500.
ChatGPT-to-API ver: latest
go version: go version go1.20.5 linux/arm64
using self-built compiled binary file

【BUG】Failed to build

Got the following error

package freechatgpt
        imports github.com/acheong08/endless
        imports github.com/acheong08/endless/signals: build constraints exclude all Go files in /Users/{user_name}/go/pkg/mod/github.com/acheong08/[email protected]/signals

OS: MacOS m2, 13.3.1 (22E261)

An error occurred when calling the gpt-4 and gpt-4-mobile models

An error occurred when calling the gpt-4 and gpt-4-mobile models. The error is as follows: {"error":{"code":"error","message":"Our systems have detected unus Ual activity from your system. Please try again later.","param":null,"type":"403 Forbidden"}}, everything is normal when gpt-3.5 is called

401 Error sending request

Yesterday it worked normally without errors.

Today there's error 401 when sending request.

[GIN-debug] GET /ping --> main.main.func1 (4 handlers)
[GIN-debug] PATCH /admin/puid --> main.puidHandler (5 handlers)
[GIN-debug] PATCH /admin/password --> main.passwordHandler (5 handlers)
[GIN-debug] PATCH /admin/tokens --> main.tokensHandler (6 handlers)
[GIN-debug] OPTIONS /v1/chat/completions --> main.optionsHandler (4 handlers)
[GIN-debug] POST /v1/chat/completions --> main.nightmare (4 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Listening and serving HTTP on 0.0.0.0:6541
[GIN] 2023/04/15 - 19:02:52 | 200 | 276.6µs | ::1 | OPTIONS "/v1/chat/completions"
API_REVERSE_PROXY set:https://bypass.churchless.tech/api/conversation
[GIN] 2023/04/15 - 19:02:53 | 401 | 960.8103ms | ::1 | POST "/v1/chat/completions"

Is it related to closing completions endpoint by OpenAI?

docker can't receive requests and access_tokens don't provided on access_tokens.txt

[GIN-debug] GET /ping --> main.main.func1 (4 handlers)
[GIN-debug] PATCH /admin/password --> main.passwordHandler (5 handlers)
[GIN-debug] PATCH /admin/tokens --> main.tokensHandler (5 handlers)
[GIN-debug] PATCH /admin/puid --> main.puidHandler (5 handlers)
[GIN-debug] OPTIONS /v1/chat/completions --> main.optionsHandler (4 handlers)
[GIN-debug] POST /v1/chat/completions --> main.nightmare (5 handlers)
2023/06/01 22:29:38 1 127.0.0.1:8080

curl http://127.0.0.1:8080/v1/chat/completions
-d '{
"model": "text-davinci-002-render-sha",
"messages": [{"role": "user", "content": "你是什么模型,是GPT3.5吗"}]
}'
curl: (56) Recv failure: Connection reset by peer

it works with docker-compose and ./freechatgpt with go but with docker build and docker run, it doesn't but raises 'curl: (56) Recv failure: Connection reset by peer' if i send request.
And I can't see my access token on the file access_tokens.txt but before i have been added my email and password on accounts.txt and touch access_tokens.txt authenticated_accounts.txt

some bugs in authenticator and API

  1. in authenticator, got 429, but I got 200 when using a browser

Location: get_access_token
Status code: 429
Details: {"details":"Rate limit exceeded"}
Embedded error: error: Check details

  1. in API, losing tailing 6 words in the response comparing with the webpage

ME: hello, how are you?
GPT: Hello! As an AI language model, I don't have feelings or emotions, but I'm functioning as intended and ready to assist you with any questions or tasks you may have. How can I assist you today?

{"id":"chatcmpl-WXlfa2FBbmROaXhpSUFyZUF3ZANvbWUF","object":"chat.completion","created":1681362002,"model":"gpt-3.5-turbo-0301","usage":{"prompt_tokens":0,"completion_tokens":0,"total_tokens":0},"choices":[{"index":0,"message":{"role":"assistant","content":"Hello! As an AI language model, I don't have feelings or emotions, but I'm functioning as intended and ready to assist you with any questions or tasks you may have."},"finish_reason":"stop"}]}

I try to open the log of the stream, and result of the stream is the same, also lack of the tailing words...

  1. Difference with the official API, when using a "system" role, got 400 bad request, should use "user" instead?
  2. a Parent_id and Conversation_id should be use to keep up with the thread ?

能否发现回复被截断后自动发送continue

chatgpt web回答内容过长,会先返回一部分,然后点击continue再返回一部分,再点击contine再返回一部分。continue是基于conversation_id的,转换成api后就无法有效的continue了。Chat-to-API能否发现回复被截断后自动发送continue。
(PS. 偶尔也遇到chatgpt的continue出问题可以无限continue,可以设定一个上限,例如最多continue 3次)

谢谢~

[Bug]: rand.Intn(n) The parameter value cannot be 0

What happened?

Normal call to /v1/chat/completions, releasing panic error.

Reason

rand.Intn(n) The parameter value cannot be 0

Solution

Modify the 66 line code in the ChatGPT-to-API/international/chatgpt/request.go file to if len(proxies) > 1 {

Console logs

2023/05/15 16:26:18 [Recovery] 2023/05/15 - 16:26:18 panic recovered:
POST /v1/chat/completions HTTP/1.1
Host: 127.0.0.1:8080
Accept: text/event-stream
Accept-Encoding: gzip
Authorization: *
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 2591
Content-Type: application/json
User-Agent: Go-http-client/1.1


invalid argument to Intn
/Users/oldwei/sdk/go1.20.3/src/math/rand/rand.go:179 (0x11418a4)
        (*Rand).Intn: panic("invalid argument to Intn")
/Users/oldwei/sdk/go1.20.3/src/math/rand/rand.go:358 (0x13974de)
        Intn: func Intn(n int) int { return globalRand.Intn(n) }
/Users/oldwei/GolandProjects/ChatGPT-to-API/internal/chatgpt/request.go:58 (0x13974d2)
        random_int: return min + rand.Intn(max-min)
/Users/oldwei/GolandProjects/ChatGPT-to-API/internal/chatgpt/request.go:67 (0x13974cf)
        SendRequest: client.SetProxy(proxies[random_int(0, len(proxies)-1)])
/Users/oldwei/GolandProjects/ChatGPT-to-API/handlers.go:85 (0x148c464)
        nightmare: response, err := chatgpt.SendRequest(translated_request, token)
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x148dc77)
        (*Context).Next: c.handlers[c.index](c)
/Users/oldwei/GolandProjects/ChatGPT-to-API/middleware.go:32 (0x148dc5e)
        cors: c.Next()
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x147e301)
        (*Context).Next: c.handlers[c.index](c)
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/recovery.go:102 (0x147e2ec)
        CustomRecoveryWithWriter.func1: c.Next()
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x147d426)
        (*Context).Next: c.handlers[c.index](c)
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/logger.go:240 (0x147d409)
        LoggerWithConfig.func1: c.Next()
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/context.go:174 (0x147c4aa)
        (*Context).Next: c.handlers[c.index](c)
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/gin.go:620 (0x147c131)
        (*Engine).handleHTTPRequest: c.Next()
/Users/oldwei/go/pkg/mod/github.com/gin-gonic/gin@v1.9.0/gin.go:576 (0x147bddc)
        (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/Users/oldwei/sdk/go1.20.3/src/net/http/server.go:2936 (0x126d135)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/Users/oldwei/sdk/go1.20.3/src/net/http/server.go:1995 (0x12699b1)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/Users/oldwei/sdk/go1.20.3/src/runtime/asm_amd64.s:1598 (0x1066ce0)
        goexit: BYTE    $0x90   // NOP

[GIN] 2023/05/15 - 16:26:18 | 500 |    2.923774ms |       127.0.0.1 | POST     "/v1/chat/completions"

Responses often get cut off

Chat GPT seems to have limit the response length and added the "Continue generating" button which makes API calls get cut off
It would be nice to have a workaround.
image

[Error code 429] Too many requests in one hour

Hi, I'm testing the server it works perfectly, so very thank you for your project!

However, I ecnouter the error 429 with the message "Too many requests in one hour"

After futher examination, this doesn't seem to be the problem with Open AI as the accounts still works as normal and after I reset the Docker container, everything works as normal.

I examined the code to try and find the limit but cannot find it. Hopes you can resolve this issues. Thank you!

【BUG】Fail to be authorized by access token

It seems that openai maybe updated it's authorization mechanism and I receive the following error message when using access token

OpenAI: {"details":{"detail":{"code":"invalid_jwt","message":"Could not parse your authentication token. Please try signing in again.","param":null,"type":"invalid_request_error"}},"error":"error sending request"}

Authentication by "continue by google"

seems the only supported auth is via user and password, is this right? the first thing I do after running is as follows which result in unauthorized:

# curl -X PATCH -H "Content-Type: application/json" -d '{"puid":"my puid key"}' http://127.0.0.1:8080/admin/puid
Unauthorized

使用gpt-4-mobile生成的内容是gpt-3的

1685950098120(1)
我:你是GPT几
回:我是GPT-3,OpenAI训练的大型语言模型。

我使用GPT4和3.5的时候是正确的
1685950318829
回:我是基于GPT-4架构的模型。
image
回:我是基于GPT-3.5架构的ChatGPT。

Proposal for Chat ID Selection Mode for Persistent Sessions

Firstly, I would like to express my sincere admiration for your outstanding project. It has been of great utility and has significantly improved the efficiency of my tasks.

I believe there is a necessity to offer a mode to select and persist a Chat ID, This has been mentioned in previous issues #30. I suggest providing a mode selection feature as follows:

1. Single Session Mode: Choose a Chat ID and continuously call it.
2. New Session Mode: Create a new session for every call.

For the Single Session Mode, I have specific use cases. I would like to pre-establish a few conversations with specific functionalities. By providing prompts to the model, certain conversations can maintain functionality such as translation or terminal simulation. This approach would make API calls to different Chat IDs much more convenient and provide specific features.

I look forward to your thoughts on this suggestion and I appreciate your consideration.

x509: certificate signed by unknown authority

When I use reverse proxy, I get the following debug error below:

{"error":"error sending requestPost \"https://bypass.churchless.tech/api/conversation\": x509: certificate signed by unknown authority"}

In correct error response format

Hi
I noticed a formatting issues when there are an error which may mess with some current app using the official API
Wrong response format:
image
Official response formatt
image

It seems auto continue doesn't work

request body:

{
     "model": "text-davinci-002-render-sha",
     "messages": [{"role": "user", "content": "introduce NYC in at least 800 words"}]
}

response body:

{
  "error": {
    "code": "error",
    "message": {
      "code": "history_disabled_conversation_not_found",
      "message": "Conversation not found"
    },
    "param": null,
    "type": "404 Not Found"
  }
}

logs:

chatgpttoapi-master  | Failed to parse JSON
chatgpttoapi-master  |  ping
chatgpttoapi-master  |
chatgpttoapi-master  | Failed to parse JSON
chatgpttoapi-master  | 2023-06-16 05:42:08.149149
chatgpttoapi-master  |
chatgpttoapi-master  | Continuing conversation
chatgpttoapi-master  | [GIN-debug] [WARNING] Headers were already written. Wanted to override status code 200 with 404
chatgpttoapi-master  | [GIN] 2023/06/16 - 05:42:12 | 200 |  20.60329566s |   192.168.99.21 | POST     "/v1/chat/completions"

Different streamed response format compared to official API

First of all, thank you so much for your wonderful work. I want to report something that may affect user when switching from Open AI API to this API

Notice in the examples below the "role" attributes are located differently.

  • In the official API, the role is passed in the first chunk along with another "content" chunk. These two chunks are streamed at the same time as you can see from the time stamp.
  • In the Chat GPT API, the "role" attribute is passed in every chunk next to the "content" attribute.

The difference may affect programs when parsing the response. It did affect mine

The official response format for streamed response:

2023-06-10 18: 11: 51 - data: {
    "id": "chatcmpl-7PxLzmRT6HFGu1ploxTA4k4ZWxnFb",
    "object": "chat.completion.chunk",
    "created": 1686420711,
    "model": "gpt-3.5-turbo-0301",
    "choices": [
        {
            "delta": {
                "role": "assistant"
            },
            "index": 0,
            "finish_reason": null
        }
    ]
}

data: {
    "id": "chatcmpl-7PxLzmRT6HFGu1ploxTA4k4ZWxnFb",
    "object": "chat.completion.chunk",
    "created": 1686420711,
    "model": "gpt-3.5-turbo-0301",
    "choices": [
        {
            "delta": {
                "content": "1"
            },
            "index": 0,
            "finish_reason": null
        }
    ]
}
2023-06-10 18: 11: 51 - data: {
    "id": "chatcmpl-7PxLzmRT6HFGu1ploxTA4k4ZWxnFb",
    "object": "chat.completion.chunk",
    "created": 1686420711,
    "model": "gpt-3.5-turbo-0301",
    "choices": [
        {
            "delta": {
                "content": "."
            },
            "index": 0,
            "finish_reason": null
        }
    ]
}
2023-06-10 18: 11: 51 - data: {
    "id": "chatcmpl-7PxLzmRT6HFGu1ploxTA4k4ZWxnFb",
    "object": "chat.completion.chunk",
    "created": 1686420711,
    "model": "gpt-3.5-turbo-0301",
    "choices": [
        {
            "delta": {
                "content": " Error"
            },
            "index": 0,
            "finish_reason": null
        }
    ]
}
...

The Chat GPT API Response format:

2023-06-10 18: 12: 16 - data: {
    "id": "chatcmpl-QXlha2FBbmROaXhpZUFyZUF3ZXNvbWUK",
    "object": "chat.completion.chunk",
    "created": 0,
    "model": "gpt-3.5-turbo-0301",
    "choices": [
        {
            "delta": {
                "content": "1. \"",
                "role": "assistant"
            },
            "index": 0,
            "finish_reason": null
        }
    ]
}
2023-06-10 18: 12: 16 - data: {
    "id": "chatcmpl-QXlha2FBbmROaXhpZUFyZUF3ZXNvbWUK",
    "object": "chat.completion.chunk",
    "created": 0,
    "model": "gpt-3.5-turbo-0301",
    "choices": [
        {
            "delta": {
                "content": "all",
                "role": "assistant"
            },
            "index": 0,
            "finish_reason": null
        }
    ]
}

how to proceed

When a question outputs half of the answer result value, how to let him continue to output the second half? Send to continue and cannot continue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.