Skip to content

paCrH50036JL/BingChatGPT-API

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BingChatGPT-API

How to run

python api.py <cookies_U>

How to get cookies_U

  1. You should be in the whitelist of Bing/new
  2. Log in Bing/new and search one time in BingChatGPT
  3. Inspect -> Application -> Cookies -> Search "_U"

Attention

Do not create conversation frequently. It might remove your account from Bing/new whitelist. :(

API usage

  1. call POST {host}/create_conversation with the body {"userId": "OlivierShi"}

The passed userId is a new-created concept in this PR, which is not the user account of Bing/new. This userId should be in the whitelist.txt and I write this simple logic to avoid too many uncontrollable requests.

It will return below information.

 {
    "conversationId": ,
    "clientId": ,
    "conversationSignature": ,
    "invocationId": 
}

image 2. call POST {host}/chatgpt with the below body,

{
  "prompt": "I love Three-Body.",
  "clientId": "",
  "conversationId": "",
  "conversationSignature": "",
  "invocationId": 0
}

where clientId, conversationId, conversationSignature and invocationId is the response from create_conversation API.

image

What is amazing

We can create multiple conversation sessions at the same time using a single Bing account with API POST {host}/create_conversation. In addition, those active sessions will not influence each other and multiple conversation can be processed independently within a single Bing account.

bing API contracts

  1. response body of https://www.bing.com/turing/conversation/create
{
    "conversationId": None,
    "clientId": None,
    "conversationSignature": None,
    "result": 
        {
            "value": "Success", 
            "message": None
        }
}
  1. request body of wss:https://sydney.bing.com/sydney/ChatHub
{
    "arguments": [
        {
            "source": "cib",
            "optionsSets": [
                "nlu_direct_response_filter",
                "deepleo",
                "enable_debug_commands",
                "disable_emoji_spoken_text",
                "responsible_ai_policy_235",
                "enablemm",
            ],
            "isStartOfSession": {isStartOfSession},
            "message": {
                "author": "user",
                "inputMethod": "Keyboard",
                "text": {prompt},
                "messageType": "Chat",
            },
            "conversationSignature": {conversation_signature},
            "participant": {
                "id": {client_id},
            },
            "conversationId": {conversationId},
        },
    ],
    "invocationId": {invocationId},
    "target": "chat",
    "type": 4,
}
  1. response body of wss:https://sydney.bing.com/sydney/ChatHub

BingChatGPT-API contracts

Create conversation

POST {host}/create_conversation

  1. request body
{
    "userId": "OlivierShi"
}
  1. response body
 {
    "conversationId": ,
    "clientId": ,
    "conversationSignature": ,
    "invocationId": 
}
  • conversationId: to identify a conversation session
  • clientId: to identify a user
  • conversationSignature: to sign the data/message for this conversation session
  • invocationId: to identify the invocation sequence. 0 stands for the first turn of a conversation.

Chat with bing chatGPT

POST {host}/chatgpt

  1. request body
 {
    "prompt": "I love watching 'Three-Body'.",
    "conversationId": ,
    "clientId": ,
    "conversationSignature": ,
    "invocationId": 
}
  1. response body
 {
    "message": "",
    "conversationId": ,
    "invocationId": 
}
  • message: is from Bing-ChatGPT
  • conversationId: to identify a conversation session, is same with request conversationId
  • invocationId: is one plus the request invocationId

Reference

https://github.com/acheong08/EdgeGPT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%