RainEggplant / chatgpt-telegram-bot

A ChatGPT bot for Telegram based on Node.js. Support both browserless and browser-base APIs.
MIT License
323 stars 97 forks source link

When using reverse proxy mode the return is not available #9

Closed suikaremilia closed 1 year ago

suikaremilia commented 1 year ago

Thank you for your work, I really enjoyed it. I am now trying to use the v4 api but am having some problems.

I have a proxy server and it seems to work fine.

curl -X POST http://xxxx.xxxx/chats -H 'Content-Type: application/json' -d '{"prompt":"who are you"}' 
{"id":"kloh-6kpPJksn7u5c5cyXmUv7oMoOdRE6t","object":"text_completion","created":1676618717,"model":"text-davinci-003","choices":[{"text":"?\n\nI am a person trying to learn more about the world.","index":0,"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":3,"completion_tokens":15,"total_tokens":18}}

And I set apiReverseProxyUrl in local.json like this:

...................
   api": {
    "version": "v4",
   },
    "v4": {
      "apiBaseUrl": "",
      "apiReverseProxyUrl": "http://xxxx.xxxx/chats",
      "completionParams": {}
    }

But when I start the bot and send a message to it in telegram, it gets stuck and doesn't get the returned value.

2/17/2023, 7:34:52 AM 📩 Message from @ () in private chat:
hello
upsertMessage dfafasfsaf-57d4-dsfa-b047-eafce922c4df {
  role: 'user',
  id: 'dfafasfsaf-57d4-dsfa-b047-eafce922c4df ',
  parentMessageId: undefined,
  conversationId: 'b4a3a4e4-d2c6-23fa-dsfa-73c5991c10bf',
  text: 'hello'
}

Is there a setting that I haven't configured correctly? Thanks

RainEggplant commented 1 year ago

The reverse proxy server is not simply proxying the ChatGPT web application, but instead simulating a set of interfaces consistent with the official completions API based on ChatGPT's response. To avoid OpenAI blocking this method, the reverse proxy server is closed-source and maintained by only a few people.

Unfortunately, according to one of the maintainers of the servers, OpenAI eventually patched this method. So it's unusable at present.

RainEggplant commented 1 year ago

Closed as this issue is related to the (legacy) reverse proxy servers, which is out of the scope of this repository.

FYI, you can now use the unofficial API with v2.1.0 to bypass CloudFlare without a browser.