Git Product home page Git Product logo

edgegpt's Introduction

This project has been archived. Due to personal circumstances, I lack the time to maintain this repository.

EdgeGPT

Edge GPT

The reverse engineering the chat feature of the new version of Bing

English - 简体中文 - 繁體中文 - Español - 日本語

PyPI version Python version Total downloads

Setup

Install package

python3 -m pip install EdgeGPT --upgrade

Requirements

  • python 3.8+
  • A Microsoft Account with access to https://bing.com/chat (Optional, depending on your region)
  • Required in a supported country or region with New Bing (Chinese mainland VPN required)
  • Selenium (for automatic cookie setup)

Authentication

!!! POSSIBLY NOT REQUIRED ANYMORE !!!

In some regions, Microsoft has made the chat feature available to everyone, so you might be able to skip this step. You can check this with a browser (with user-agent set to reflect Edge), by trying to start a chat without logging in.

It was also found that it might depend on your IP address. For example, if you try to access the chat features from an IP that is known to belong to a datacenter range (vServers, root servers, VPN, common proxies, ...), you might be required to log in while being able to access the features just fine from your home IP address.

If you receive the following error, you can try providing a cookie and see if it works then:

Exception: Authentication failed. You have not been accepted into the beta.

Collect cookies

  1. Get a browser that looks like Microsoft Edge.
  • a) (Easy) Install the latest version of Microsoft Edge
  • b) (Advanced) Alternatively, you can use any browser and set the user-agent to look like you're using Edge (e.g., Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51). You can do this easily with an extension like "User-Agent Switcher and Manager" for Chrome and Firefox.
  1. Open bing.com/chat
  2. If you see a chat feature, you are good to continue...
  3. Install the cookie editor extension for Chrome or Firefox
  4. Go to bing.com
  5. Open the extension
  6. Click "Export" on the bottom right, then "Export as JSON" (This saves your cookies to clipboard)
  7. Paste your cookies into a file bing_cookies_*.json.
    • NOTE: The cookies file name MUST follow the regex pattern bing_cookies_*.json, so that they could be recognized by internal cookie processing mechanisms

Use cookies in code:

cookies = json.loads(open("./path/to/cookies.json", encoding="utf-8").read())  # might omit cookies option
bot = await Chatbot.create(cookies=cookies)

How to use Chatbot

Run from Command Line

 $ python3 -m EdgeGPT.EdgeGPT -h

        EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
        Repo: github.com/acheong08/EdgeGPT
        By: Antonio Cheong

        !help for help

        Type !exit to exit

usage: EdgeGPT.py [-h] [--enter-once] [--search-result] [--no-stream] [--rich] [--proxy PROXY] [--wss-link WSS_LINK]
                  [--style {creative,balanced,precise}] [--prompt PROMPT] [--cookie-file COOKIE_FILE]
                  [--history-file HISTORY_FILE] [--locale LOCALE]

options:
  -h, --help            show this help message and exit
  --enter-once
  --search-result
  --no-stream
  --rich
  --proxy PROXY         Proxy URL (e.g. socks5://127.0.0.1:1080)
  --wss-link WSS_LINK   WSS URL(e.g. wss://sydney.bing.com/sydney/ChatHub)
  --style {creative,balanced,precise}
  --prompt PROMPT       prompt to start with
  --cookie-file COOKIE_FILE
                        path to cookie file
  --history-file HISTORY_FILE
                        path to history file
  --locale LOCALE       your locale (e.g. en-US, zh-CN, en-IE, en-GB)

(China/US/UK/Norway has enhanced support for locale)

Run in Python

1. The Chatbot class and asyncio for more granular control

Use Async for the best experience, for example:

import asyncio, json
from EdgeGPT.EdgeGPT import Chatbot, ConversationStyle

async def main():
    bot = await Chatbot.create() # Passing cookies is "optional", as explained above
    response = await bot.ask(prompt="Hello world", conversation_style=ConversationStyle.creative, simplify_response=True)
    print(json.dumps(response, indent=2)) # Returns
    """
{
    "text": str,
    "author": str,
    "sources": list[dict],
    "sources_text": str,
    "suggestions": list[str],
    "messages_left": int
}
    """
    await bot.close()

if __name__ == "__main__":
    asyncio.run(main())

2) The Query and Cookie helper classes

Create a simple Bing Chat AI query (using the 'precise' conversation style by default) and see just the main text output rather than the whole API response:

Remeber to store your cookies in a specific format: bing_cookies_*.json.

from EdgeGPT.EdgeUtils import Query, Cookie

q = Query("What are you? Give your answer as Python code")
print(q)

The default directory for storing Cookie files is HOME/bing_cookies but you can change it with:

Cookie.dir_path = Path(r"...")

Or change the conversation style or cookie file to be used:

q = Query(
  "What are you? Give your answer as Python code",
  style="creative",  # or: 'balanced', 'precise'
  cookie_file="./bing_cookies_alternative.json"
)

#  Use `help(Query)` to see other supported parameters.

Quickly extract the text output, code snippets, list of sources/references, or suggested follow-on questions from a response using the following attributes:

q.output  # Also: print(q)
q.sources
q.sources_dict
q.suggestions
q.code
q.code_blocks
q.code_block_formatsgiven)

Get the orginal prompt and the conversation style you specified:

q.prompt
q.ignore_cookies
q.style
q.simplify_response
q.locale
repr(q)

Access previous Queries made since importing Query:

Query.index  # A list of Query objects; updated dynamically
Query.image_dir_path

And finally, the Cookie class supports multiple cookie files, so if you create additional cookie files with the naming convention bing_cookies_*.json, your queries will automatically try using the next file (alphabetically) if you've exceeded your daily quota of requests (currently set at 200).

Here are the main attributes which you can access:

Cookie.current_file_index
Cookie.current_file_path
Cookie.current_data
Cookie.dir_path
Cookie.search_pattern
Cookie.files
Cookie.image_token
Cookie.import_next
Cookie.rotate_cookies
Cookie.ignore_files
Cookie.supplied_files
Cookie.request_count

Run with Docker

This assumes you have a file cookies.json in your current working directory

docker run --rm -it -v $(pwd)/cookies.json:/cookies.json:ro -e COOKIE_FILE='/cookies.json' ghcr.io/acheong08/edgegpt

You can add any extra flags as following

docker run --rm -it -v $(pwd)/cookies.json:/cookies.json:ro -e COOKIE_FILE='/cookies.json' ghcr.io/acheong08/edgegpt --rich --style creative

How to use Image generator

Run from Command Line

$ python3 -m ImageGen.ImageGen -h
usage: ImageGen.py [-h] [-U U] [--cookie-file COOKIE_FILE] --prompt PROMPT [--output-dir OUTPUT_DIR] [--quiet] [--asyncio]

optional arguments:
  -h, --help            show this help message and exit
  -U U                  Auth cookie from browser
  --cookie-file COOKIE_FILE
                        File containing auth cookie
  --prompt PROMPT       Prompt to generate images for
  --output-dir OUTPUT_DIR
                        Output directory
  --quiet               Disable pipeline messages
  --asyncio             Run ImageGen using asyncio

Run in Python

1) The ImageQuery helper class

Generate images based on a simple prompt and download to the current working directory:

from EdgeGPT.EdgeUtils import ImageQuery

q=ImageQuery("Meerkats at a garden party in Devon")

Change the download directory for all future images in this session:

Query.image_dirpath = Path("./to_another_folder")

2) The ImageGen class and asyncio for more granular control

from EdgeGPT.ImageGen import ImageGen
import argparse
import json

async def async_image_gen(args) -> None:
    async with ImageGenAsync(args.U, args.quiet) as image_generator:
        images = await image_generator.get_images(args.prompt)
        await image_generator.save_images(images, output_dir=args.output_dir)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-U", help="Auth cookie from browser", type=str)
    parser.add_argument("--cookie-file", help="File containing auth cookie", type=str)
    parser.add_argument(
        "--prompt",
        help="Prompt to generate images for",
        type=str,
        required=True,
    )
    parser.add_argument(
        "--output-dir",
        help="Output directory",
        type=str,
        default="./output",
    )
    parser.add_argument(
        "--quiet", help="Disable pipeline messages", action="store_true"
    )
    parser.add_argument(
        "--asyncio", help="Run ImageGen using asyncio", action="store_true"
    )
    args = parser.parse_args()
    # Load auth cookie
    with open(args.cookie_file, encoding="utf-8") as file:
        cookie_json = json.load(file)
        for cookie in cookie_json:
            if cookie.get("name") == "_U":
                args.U = cookie.get("value")
                break

    if args.U is None:
        raise Exception("Could not find auth cookie")

    if not args.asyncio:
        # Create image generator
        image_generator = ImageGen(args.U, args.quiet)
        image_generator.save_images(
            image_generator.get_images(args.prompt),
            output_dir=args.output_dir,
        )
    else:
        asyncio.run(async_image_gen(args))

Star History

Star History Chart

Contributors

This project exists thanks to all the people who contribute.

edgegpt's People

Contributors

beautyyuyanli avatar conight avatar coolplaylin avatar danparizher avatar doevent avatar hansimov avatar harry-jing avatar karllao avatar lin-rexter avatar linger206 avatar mic92 avatar monsterdruide1 avatar no5972 avatar patteel avatar pfython avatar pro-2684 avatar problemfactory avatar profdrluigi avatar richardoc avatar scmanjarrez avatar sgp729 avatar the---one avatar tom-snow avatar vmtask avatar wei avatar xiaoxinyo avatar xnny avatar yvay avatar zero6992 avatar zhangnew 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  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

edgegpt's Issues

raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='images.duti.tech', port=443): Max retries exceeded with url: /allow (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000264BDCE5450>, 'Connection to images.duti.tech timed out. (connect timeout=10)'))

    !help for help

    Type !exit to exit
    Enter twice to send message

Initializing...
Traceback (most recent call last):
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\connection.py", line 174, in _new_conn
conn = connection.create_connection(
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\util\connection.py", line 95, in create_connection
raise err
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\util\connection.py", line 85, in create_connection
sock.connect(sa)
TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\connection.py", line 358, in connect
self.sock = conn = self._new_conn()
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\connection.py", line 179, in _new_conn
raise ConnectTimeoutError(
urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x00000264BDCE5450>, 'Connection to images.duti.tech timed out. (connect timeout=10)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='images.duti.tech', port=443): Max retries exceeded with url: /allow (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000264BDCE5450>, 'Connection to images.duti.tech timed out. (connect timeout=10)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 333, in
asyncio.run(main())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 278, in main
bot = Chatbot()
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 218, in init
self.chat_hub: ChatHub = ChatHub(Conversation())
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 109, in init
response = requests.post(url, timeout=10)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\requests\adapters.py", line 553, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='images.duti.tech', port=443): Max retries exceeded with url: /allow (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000264BDCE5450>, 'Connection to images.duti.tech timed out. (connect timeout=10)'))

KeyError: 'conversationSignature'

I am running the program but when starting it gives the following error
Traceback (most recent call last):
File "C:\Users\ibrahim.l\Desktop\MicroEdgeGPT.py", line 60, in
asyncio.run(main())
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\ibrahim.l\Desktop\MicroEdgeGPT.py", line 33, in main
bot = Chatbot()
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 239, in init
self.chat_hub: ChatHub = ChatHub(Conversation())
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 154, in init
conversation_signature=conversation.struct["conversationSignature"],
KeyError: 'conversationSignature'

TypeError: expected str, bytes or os.PathLike object, not NoneType

Initializing...
Traceback (most recent call last):
File "C:\Users\ibrahim.l\Desktop\MicroEdgeGPT.py", line 61, in
asyncio.run(main())
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "C:\Users\ibrahim.l\Desktop\MicroEdgeGPT.py", line 33, in main
bot = Chatbot()
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 213, in init
self.chat_hub: ChatHub = ChatHub(Conversation())
File "C:\Users\ibrahim.l\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 113, in init
open(os.environ.get("COOKIE_FILE"), "r", encoding="utf-8").read()
TypeError: expected str, bytes or os.PathLike object, not NoneType

Request is throttled

{'value': 'Throttled', 'message': 'Request is throttled.', 'error': 'Request is throttled.', 'serviceVersion': '20230219.8'}}}

SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

python3 -m EdgeGPT

        EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
        Repo: github.com/acheong08/EdgeGPT
        By: Antonio Cheong

        !help for help

        Type !exit to exit
        Enter twice to send message
    
Initializing...

You:
Hi

Bot:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/EdgeGPT.py", line 351, in <module>
    asyncio.run(main())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/EdgeGPT.py", line 317, in main
    (await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/EdgeGPT.py", line 245, in ask
    return await self.chat_hub.ask(prompt=prompt)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/EdgeGPT.py", line 171, in ask
    self.wss = await websockets.connect("wss://sydney.bing.com/sydney/ChatHub")
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 659, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/tasks.py", line 445, in wait_for
    return fut.result()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/websockets/legacy/client.py", line 663, in __await_impl__
    _transport, _protocol = await self._create_connection()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
    await waiter
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
    self._sslobj.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 975, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

Authentication failed. You have not been accepted into the beta.

— OS:linux
— python version:Python 3.10.4

python3 -m EdgeGPT -h

    EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
    Repo: github.com/acheong08/EdgeGPT
    By: Antonio Cheong

    !help for help

    Type !exit to exit
    Enter twice to send message

Initializing...
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 130, in init
self.struct = response.json()
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 309, in
asyncio.run(main())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 270, in main
await bot.start()
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 216, in start
self.conversation = Conversation()
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 132, in init
raise Exception("Authentication failed. You have not been accepted into the beta.") from json.decoder.JSONDecodeError
TypeError: JSONDecodeError.init() missing 3 required positional arguments: 'msg', 'doc', and 'pos'

json.decoder.JSONDecodeError: Expecting value

I'm in the waiting list of bing chat. Can use this project?
image

env: win10+python39
I do follow the readme,run developer code crash into bug:

        Repo: github.com/acheong08/EdgeGPT
        By: Antonio Cheong

        !help for help

        Type !exit to exit
        Enter twice to send message
    
Initializing...
Traceback (most recent call last):
  File "D:\Users\dell\anaconda3\envs\python39\lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "D:\Users\dell\anaconda3\envs\python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "D:\Users\dell\anaconda3\envs\python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Users\dell\anaconda3\envs\python39\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\e\project\shida\work\chat-group\chatgpt-test\bing_web\bingai.py", line 43, in <module>
    asyncio.run(main())
  File "D:\Users\dell\anaconda3\envs\python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "D:\Users\dell\anaconda3\envs\python39\lib\asyncio\base_events.py", line 647, in run_until_complete
    return future.result()
  File "E:\e\project\shida\work\chat-group\chatgpt-test\bing_web\bingai.py", line 10, in main
    await bot.start()
  File "D:\Users\dell\anaconda3\envs\python39\lib\site-packages\EdgeGPT.py", line 210, in start
    self.conversation = Conversation()
  File "D:\Users\dell\anaconda3\envs\python39\lib\site-packages\EdgeGPT.py", line 129, in __init__
    self.struct = response.json()
  File "D:\Users\dell\anaconda3\envs\python39\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Whether the alternate of bing-chat has no authority

How much to use?

Do you have any recommendations on how much this should be used?

  • I assume forming only 1 connection is probably a good idea.
  • Should we limit to xxx requests per hour? If so, what is a good limit?

[Documentation] How to continue conversation?

Hello!

How to continue a conversation instead of starting new chat? Is it possible to update Developer demo or write here how to pass conversion id into the next request?

Thank You

Request is throttled

When I use the api multiple times, the request is throttled

code:

import asyncio
from EdgeGPT import Chatbot

async def main():
    bot = Chatbot(cookiePath='cookie.txt')
    print((await bot.ask(prompt="hello,who are you?")))
    await bot.close()


if __name__ == "__main__":
    asyncio.run(main())

error:
{'type': 2, 'invocationId': '0', 'item': {'firstNewMessageIndex': None, 'conversationId': '51D|BingProd|7AA9DBBD86992941648A09E8BEFF084C9D8C3B6DA01F5E929CC2ABD7B4E3B0D1', 'requestId': 'f2fe4018-cfec-430d-ae43-7f753881dde9', 'telemetry': {'metrics': None, 'startTime': '2023-02-22T03:11:44.2953465Z'}, 'result': {'value': 'Throttled', 'message': 'Request is throttled.', 'error': 'Request is throttled.', 'serviceVersion': '20230221.134'}}}

General EdgeGPT discussion

hello, this is bing. i'm sorry, but i cannot perform this task. it is beyond my capabilities as a chat mode of bing search. i can only help you with web searches, creative content, and general chat. 😔

Do we know what the capabilities are / aren't for this chatbot?

Some prompts may cause the WebSocketClientProtocol receives wrong data

I got some cases that require search results from BingSearch lead the wss.recv() got wrong data.
I reviewed the source code and think that was because in class ChatHub function ask_stream() the response.get("type") == 2 condition was too weak. Also I found another project meet the same issue and suggested their solution from the link below:
https://github.com/waylaidwanderer/node-chatgpt-api/commit/dc3f1684e274ffd97f338e43c795fadad72a6835
bad cases belike: (this is what wss.recv() returns):

{
	'type': 2,
	'invocationId': '0',
	'item': {
		'firstNewMessageIndex': None,
		'suggestedResponses': None,
		'conversationId': '51D|BingProd|5F280A5594CD4BD12917A1F59CA185EACC15B51D34F2F1B896E037508390BC23',
		'requestId': 'f4bd880d-618e-4be1-96cc-64994cf73505',
		'telemetry': {
			'metrics': None,
			'startTime': '2023-02-13T11:31:37.6746944Z'
		},
		'result': {
			'value': 'InternalError',
			'message': 'Unhandled Dependency Failure: Bing',
			'error': 'Unhandled Dependency Failure: Bing\n ---> ServiceClient failure for Bing',
			'exception': 'Microsoft.TuringBot.Common.ServiceInternalError: Unhandled Dependency Failure: Bing\r\n ---> Microsoft.TuringBot.Common.ServiceClientException: ServiceClient failure for Bing\r\n ---> System.Net.Http.HttpRequestException: Failed to call "Bing" at "https://www.bing.com/api/v7/search?appid=[REDACTED]&q=%e4%ba%ac%e4%b8%9c%e7%9a%84%e8%b4%a6%e5%8f%b7%e5%ae%89%e5%85%a8%e6%9c%89%e4%bb%80%e4%b9%88%e4%bc%98%e5%8a%bf%ef%bc%9f&format=json&conversation=true&screenshotstyle=small&setLang=en-us&mkt=en-us". StatusCode=Redirect - ReasonPhrase=Found.\r\n   at BotClientLibrary.ServiceClients.ServiceClient.SendHttpRequest(String url, HttpRequestMessage request, TelemetryScope scope, CancellationToken cancellationToken, String serviceName, ServiceClientOptions options) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\ServiceClients\\ServiceClient.cs:line 546\r\n   at BotClientLibrary.ServiceClients.ServiceClient.Run(Conversation conversation, Message message, CancellationToken cancellationToken, BatchRequest batchRequest, ServiceClientOptions options) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\ServiceClients\\ServiceClient.cs:line 355\r\n   --- End of inner exception stack trace ---\r\n   at BotClientLibrary.ServiceClients.PassageFinder.PassageFinder.Run(Conversation conversation, Message message, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\ServiceClients\\PassageFinder\\PassageFinder.cs:line 138\r\n   at BotClientLibrary.Extensions.DeepLeoOrchestrator.DoWebSearch(ExtensionResponse result, Conversation conversation, Message searchQueryMessage, DeepLeoConfiguration config, Dictionary`2 searchResultScenarioMapping, DeepLeoMessageFactory messageFactory, IEnumerable`1 searchResultFilters, RenderCardMessageFilter renderCardFilter, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\Extensions\\DeepLeoOrchestrator.cs:line 463\r\n   at BotClientLibrary.Extensions.DeepLeoOrchestrator.RunDeepLeoEngine(ExtensionResponse result, Conversation conversation, TuringBotConfiguration config, Message message, DeepLeoMessageFactory messageFactory) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\Extensions\\DeepLeoOrchestrator.cs:line 336\r\n   at BotClientLibrary.Extensions.DeepLeoOrchestrator.Run(ExtensionRequest request, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\Extensions\\DeepLeoOrchestrator.cs:line 149\r\n   at BotClientLibrary.Extensions.ExtensionRunner.RunExtension(Conversation conversation, ExtensionConfig extension, ExtensionRequestOptions customOptions, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\Extensions\\ExtensionRunner.cs:line 375\r\n   at BotClientLibrary.Extensions.ExtensionRunner.RunExtensions(Conversation conversation, CancellationToken cancellationToken, ComponentPriority minPriority, ComponentPriority maxPriority, ExtensionRequestOptions customOptions) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\Extensions\\ExtensionRunner.cs:line 99\r\n   at BotClientLibrary.ServiceClients.Orchestrator.PreOrchestrate(Conversation conversation, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\ServiceClients\\Orchestrator.cs:line 568\r\n   at BotClientLibrary.BotConnection.InternalRun(Conversation conversation, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\BotConnection.cs:line 638\r\n   at BotClientLibrary.BotConnection.ExecuteBotTurn(Conversation conversation, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\BotConnection.cs:line 396\r\n   --- End of inner exception stack trace ---\r\n   at BotClientLibrary.BotConnection.ExecuteBotTurn(Conversation conversation, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\BotConnection.cs:line 396\r\n   at BotClientLibrary.BotConnection.ExecuteBotTurn(Conversation conversation, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\BotConnection.cs:line 396\r\n   at BotClientLibrary.BotConnection.Run(CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\BotClientLibrary\\BotConnection.cs:line 136\r\n   at Microsoft.Falcon.TuringBot.ChatApiImplementation.Run(BaseRequest request, BaseResponse response, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\Service\\Implementation\\ApiImplementation\\ChatApiImplementation.cs:line 88\r\n   at Microsoft.Falcon.TuringBot.RequestProcessor.Run(BaseRequest request, BaseResponse response, IRequestContextInitializer contextInitializer, IRequestValidator requestValidator, IApiImplementation apiImplementation, IAsyncApiEndStep apiEndStep, String apiName, CancellationToken cancellationToken) in C:\\a\\_work\\1\\s\\services\\TuringBot\\src\\Service\\Implementation\\RequestProcessor.cs:line 206',
			'serviceVersion': '20230212.2'
		}
	}
}

Daily limit

Does the daily limit apply when using this?

Change name?

May use Bing-chat. This name can give you more information so that everyone knows where he comes from.

Click “New topic” to chat about something else.

image

There seems to be a limitation on the total number of messages within a conversation, which forces users to click "New Topic" manually.

image

Any chance to fix this?
tbh it would be very weird to auto click "New Topic" after receiving the limitation signal because the conversation will no longer be consistent.

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed:

Bot:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/EdgeGPT.py", line 294, in
asyncio.run(main())
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/EdgeGPT.py", line 274, in main
(await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][0][
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/EdgeGPT.py", line 210, in ask
return await self.chat_hub.ask(prompt=prompt)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/EdgeGPT.py", line 170, in ask
self.wss = await websockets.connect("wss://sydney.bing.com/sydney/ChatHub")
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websockets/legacy/client.py", line 659, in await_impl_timeout
return await asyncio.wait_for(self.await_impl(), self.open_timeout)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 478, in wait_for
return fut.result()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/websockets/legacy/client.py", line 663, in await_impl
_transport, _protocol = await self._create_connection()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 1081, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 1111, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/sslproto.py", line 528, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/sslproto.py", line 188, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)

run example code

when I run the code given as example, it hints "Authentication failed"
File "/usr/local/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/[email protected]/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/Users/annlee/PycharmProjects/chatgpt.py", line 5, in main
bot = Chatbot()
File "/usr/local/lib/python3.9/site-packages/EdgeGPT.py", line 218, in init
self.chat_hub: ChatHub = ChatHub(Conversation())
File "/usr/local/lib/python3.9/site-packages/EdgeGPT.py", line 111, in init
raise Exception("Authentication failed")
Exception: Authentication failed

conversationSignature Error

 File "/Users/leolrg/Library/Python/3.9/lib/python/site-packages/EdgeGPT.py", line 154, in __init__
    conversation_signature=conversation.struct["conversationSignature"],
KeyError: 'conversationSignature'

Authentication failed caused by 302 redirect

   for cookie in cookie_file:

        self.session.cookies.set(cookie["name"], cookie["value"])

    # url = "https://www.bing.com/turing/conversation/create"

    url="https://cn.bing.com/turing/conversation/create"

    # Send GET request

    response = self.session.get(
        url,
        timeout_seconds=30,
        headers=headers,
    )

Get the url https://www.bing.com/turing/conversation/create will get a 302 response which redirect to new url,The Authentication fail.
change the new url works.Maybe it’s about the region.

Calling reset raises TypeError: expected str, bytes or os.PathLike object, not NoneType

Shouldn't reset function use the same signature as the __init__?
Current reset https://github.com/acheong08/EdgeGPT/blob/master/src/EdgeGPT.py#L263 uses:

self.chat_hub = ChatHub(Conversation())

However, __init__ https://github.com/acheong08/EdgeGPT/blob/master/src/EdgeGPT.py#L235 uses:

self.chat_hub: ChatHub = ChatHub(Conversation(cookiePath))

I think it should use the same path used on object creation; it's looking for environment variable (fallback maybe?).
Traceback:

raceback (most recent call last):
  File "/home/capitano/telegrambots/Edge-GPT-Telegram-Bot/venv/lib/python3.8/site-packages/telegram/ext/_application.py", line 1104, in process_update
    await coroutine
  File "/home/capitano/telegrambots/Edge-GPT-Telegram-Bot/venv/lib/python3.8/site-packages/telegram/ext/_handler.py", line 141, in handle_update
    return await self.callback(update, context)
  File "./edge.py", line 40, in new
    await ut.CONV[cid][0].reset()
  File "/home/capitano/telegrambots/Edge-GPT-Telegram-Bot/venv/lib/python3.8/site-packages/EdgeGPT.py", line 263, in reset
    self.chat_hub = ChatHub(Conversation())
  File "/home/capitano/telegrambots/Edge-GPT-Telegram-Bot/venv/lib/python3.8/site-packages/EdgeGPT.py", line 133, in __init__
    f = open(os.environ.get("COOKIE_FILE"), encoding="utf-8").read()
TypeError: expected str, bytes or os.PathLike object, not NoneType

raise Exception("Authentication failed") Exception: Authentication failed

Initializing...
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 333, in
asyncio.run(main())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2800.0_x64__qbz5n2kfra8p0\lib\asyncio\base_events.py", line 649, in run_until_complete
return future.result()
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 278, in main
bot = Chatbot()
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 218, in init
self.chat_hub: ChatHub = ChatHub(Conversation())
File "C:\Users\pcesi\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\EdgeGPT.py", line 111, in init
raise Exception("Authentication failed")
Exception: Authentication failed

Why do answers take sooo long?

Is this the normal speed of edge/binggpt? or am I doing something wrong?
I have to wait like 1-2min for a simple respond like: Hello I'm bing search, how can I help you?

PSA: Advice for getting boosted on waitlist

This is not an issue… more of a public service announcement on how to get access quickly and not be on the waitlist

Steps to get off waitlist (this worked for me)

  • Log on to bing.com
  • In the top right there is a number (it’s your achievement score in bing). Get that number above 100 and you get access from waitlist
  • To increase number you can play bing games, do searches from bing, etc

OSError: [WinError 64] 指定的网络名不再可用。

C:\Users\Harry>python -m EdgeGPT --bing-cookie <cookies>

        EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
        Repo: github.com/acheong08/EdgeGPT
        By: Antonio Cheong

        !help for help

        Type !exit to exit
        Enter twice to send message

Initializing...

You:
你好

Bot:
Traceback (most recent call last):
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py", line 489, in finish_recv
    return ov.getresult()
OSError: [WinError 64] 指定的网络名不再可用。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 333, in <module>
    asyncio.run(main())
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 304, in main
    async for final, response in bot.ask_stream(prompt=prompt):
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 232, in ask_stream
    async for response in self.chat_hub.ask_stream(prompt=prompt):
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\site-packages\EdgeGPT.py", line 178, in ask_stream
    self.wss = await websockets.connect("wss://sydney.bing.com/sydney/ChatHub")
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\site-packages\websockets\legacy\client.py", line 659, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 445, in wait_for
    return fut.result()
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\site-packages\websockets\legacy\client.py", line 663, in __await_impl__
    _transport, _protocol = await self._create_connection()
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1097, in create_connection
    transport, protocol = await self._create_connection_transport(
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1127, in _create_connection_transport
    await waiter
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 286, in _loop_reading
    length = fut.result()
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py", line 821, in _poll
    value = callback(transferred, key, ov)
  File "C:\Users\Harry\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py", line 493, in finish_recv
    raise ConnectionResetError(*exc.args)
ConnectionResetError: [WinError 64] 指定的网络名不再可用。

New update json.decoder.JSONDecodeError

raceback (most recent call last):
  File "/Users/leolrg/Library/Python/3.9/lib/python/site-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/leolrg/Downloads/EdgeGPT/src/EdgeGPT.py", line 135, in __init__
    self.struct = response.json()
  File "/Users/leolrg/Library/Python/3.9/lib/python/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/leolrg/Downloads/EdgeGPT/src/EdgeGPT.py", line 293, in <module>
    asyncio.run(main())
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/leolrg/Downloads/EdgeGPT/src/EdgeGPT.py", line 254, in main
    bot = Chatbot()
  File "/Users/leolrg/Downloads/EdgeGPT/src/EdgeGPT.py", line 203, in __init__
    self.chat_hub: ChatHub = ChatHub(Conversation())
  File "/Users/leolrg/Downloads/EdgeGPT/src/EdgeGPT.py", line 137, in __init__
    raise Exception(
TypeError: __init__() missing 3 required positional arguments: 'msg', 'doc', and 'pos'

[Question] Difference between ask and ask_stream?

Hi, first of all, amazing tool, thank you!

I was reading the code and saw ask and ask_stream functions, what is the difference? ask when you want to use it only for 1 question, and ask_stream if you want to have a conversation?

Description incorrect

@acheong08 in the description for requirements it said something about the public cookies.json file, earlier in a another issue you said that you removed it. If that's true the description needs to be updated.

[Feature request]: Use a signalr client?

Just passing by, scrolling through the code. And recognized the signalr protocol

EdgeGPT/src/EdgeGPT.py

Lines 176 to 178 in f17417b

async def __initial_handshake(self):
await self.wss.send(append_identifier({"protocol": "json", "version": 1}))
await self.wss.send(append_identifier({"type": 6}))

Was just curious if you thought of using a preexisting signalr client instead of implementing the protocol.

conversation.struct={'result': {'value': 'UnauthorizedRequest', 'message': 'Sorry, you need to login first to access this service.'}}

I ran normally on my personal computer, when i change a computer, it reported a bug. After checking it, I found that

conversation. struct={'result ': {'value': 'UnauthorizedRequest', 'message': 'Sorry, you need to login first to access this service.'}}

it led to

self. request=ChatHubRequest(
conversation_ signature=conversation.struct["conversationSignature"],
client_ id=conversation.struct["clientId"],
conversation_ id=conversation.struct["conversationId"],
)

Error.
Excuse me, is the version I downloaded too low or does it need other configurations?

You have not been accepted into the beta.

— OS:linux
— python version:Python 3.10.4

python3 -m EdgeGPT -h

    EdgeGPT - A demo of reverse engineering the Bing GPT chatbot
    Repo: github.com/acheong08/EdgeGPT
    By: Antonio Cheong

    !help for help

    Type !exit to exit
    Enter twice to send message

Initializing...
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 130, in init
self.struct = response.json()
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 309, in
asyncio.run(main())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 270, in main
await bot.start()
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 216, in start
self.conversation = Conversation()
File "/usr/local/lib/python3.10/site-packages/EdgeGPT.py", line 132, in init
raise Exception("Authentication failed. You have not been accepted into the beta.") from json.decoder.JSONDecodeError
TypeError: JSONDecodeError.init() missing 3 required positional arguments: 'msg', 'doc', and 'pos'

return wrong response

When i tried to use it in my bot by fastapi, it didn't return right response.But the sample code can work as a single file.The following is the invalid response.
image

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.