acheong08 / ChatGPT

Reverse engineered ChatGPT API
GNU General Public License v2.0
28.01k stars 4.48k forks source link

[Feature Request]: Add support for browsing (not compatible currently) #1375

Closed noname01t1 closed 1 year ago

noname01t1 commented 1 year ago

Is there an existing issue for this?

What would your feature do ?

To support the latest model: gpt-4-browsing

Proposed workflow

Working when "model" is set to "gpt-4-browsing"

Additional information

Current error:

'parts'
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/root/<privacy delete>.py", line <privacy delete>, in ask
    for data in chatbot[i].ask(
  File "/usr/local/lib/python3.9/dist-packages/revChatGPT/V1.py", line 575, in ask
    yield from self.post_messages(
  File "/usr/local/lib/python3.9/dist-packages/revChatGPT/V1.py", line 530, in post_messages
    yield from self.__send_request(
  File "/usr/local/lib/python3.9/dist-packages/revChatGPT/V1.py", line 414, in __send_request
    message: str = line["message"]["content"]["parts"][0]
KeyError: 'parts'

If I get enough time, I'll try to submit a PR.

github-actions[bot] commented 1 year ago

Automated: 👋 Thanks for reporting this issue. @acheong08 will review it shortly. In the meantime, please check to see if there are any similar issues already closed.

acheong08 commented 1 year ago

I currently don't have access to browsing and thus can't reverse on my own. Please provide a sample browsing request and the resulting stream. You can find this from F12

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 2 days with no activity.

Erol444 commented 1 year ago

Hi @acheong08 , So I am not entirely sure what yalls approach is (using openai's official API / using sockets for their chat.openai.com / using browser to navigate there / etc.) but this is the POST request to https://chat.openai.com/backend-api/conversation inside the chat.openai.com when you select GPT4 browsing:

{
  "action": "next",
  "messages": [
    {
      "id": "aaa23ff3-1dc4-42c7-8e31-5dc9abbed21f",
      "author": { "role": "user" },
      "content": {
        "content_type": "text",
        "parts": [
          "What's the age difference between dua lipa and her boyfriend?"
        ]
      }
    }
  ],
  "parent_message_id": "aaa1f5d0-a18a-4619-95f7-0fc0ecd7b1bf",
  "model": "gpt-4-browsing",
  "timezone_offset_min": -120,
  "history_and_training_disabled": false
}

Would that help?

acheong08 commented 1 year ago

Thanks. That is exactly what I was looking for. Will work on this soon

acheong08 commented 1 year ago

Can you send the corresponding response?

acheong08 commented 1 year ago

I have no way of testing it but based on the original issue, the problems seems to be parsing

acheong08 commented 1 year ago

Even without access to it on the web interface, sending the request got me access (I think)

{
  "message": {
    "id": "0826472e-c9e3-498d-93ae-75b9aec7e8ff",
    "author": {
      "role": "assistant",
      "name": null,
      "metadata": {}
    },
    "create_time": 1684637522.627016,
    "update_time": null,
    "content": {
      "content_type": "text",
      "parts": [
        "..."
      ]
    },
    "status": "finished_successfully",
    "end_turn": true,
    "weight": 1,
    "metadata": {
      "message_type": "next",
      "model_slug": "gpt-4-browsing",
      "citations": [
        {
          "start_ix": 356,
          "end_ix": 366,
          "metadata": {
            "title": "apnews.com",
            "url": "https://apnews.com/hub/joe-biden",
            "text": "...",
            "pub_date": null
          }
        },
        {
          "start_ix": 366,
          "end_ix": 377,
          "metadata": {
            "title": "apnews.com",
            "url": "https://apnews.com/hub/joe-biden",
            "text": "...",
            "pub_date": null
          }
        }
      ],
      "finish_details": {
        "type": "stop",
        "stop": "<|diff_marker|>"
      }
    },
    "recipient": "all"
  },
  "conversation_id": "65453023-2a02-47e0-8cf8-069b06759841",
  "error": null
}
acheong08 commented 1 year ago

Parsing issues come from

{
  "message": {
    "id": "23b01f22-5c70-4e62-b398-0c6f3da28f04",
    "author": {
      "role": "tool",
      "name": "browser",
      "metadata": {}
    },
    "create_time": null,
    "update_time": null,
    "content": {
      "content_type": "tether_browsing_display",
      "result": "",
      "summary": ""
    },
    "status": "finished_successfully",
    "end_turn": null,
    "weight": 0,
    "metadata": {
      "command": "search",
      "status": "running",
      "args": [
        "latest news on Joe Biden"
      ],
      "message_type": "next",
      "model_slug": "gpt-4-browsing"
    },
    "recipient": "all"
  },
  "conversation_id": "65453023-2a02-47e0-8cf8-069b06759841",
  "error": null
}
acheong08 commented 1 year ago

Done