acheong08 / EdgeGPT

Reverse engineered API of Microsoft's Bing Chat AI
The Unlicense
8.09k stars 913 forks source link

[Bug]: Status code: 502 - prints HTML page into console #543

Open Seminko opened 1 year ago

Seminko commented 1 year ago

Is there an existing issue for this?

What happened?

From time to time, EdgeGPT apparently gets a 502 and decides to print the whole HTML into console.

Cloudflare is mentioned...

Steps to reproduce the problem

Don't know how to reproduce

What should have happened?

The whole HTML should not have been prited. Whether the http status should have been printed is debatable.

Version where the problem happens

0.10.13

What Python version are you running this with?

3.9.16

What is your operating system ?

Windows

Command Line Arguments

None

Console logs

Block of code ``` Status code: 502 edge.churchless.tech | 502: Bad gateway

Bad gateway Error code 502

Visit cloudflare.com for more information.
2023-06-14 09:52:23 UTC
You

Browser

Working
Prague

Cloudflare

Working
edge.churchless.tech

Host

Error

What happened?

The web server reported a bad gateway error.

What can I do?

Please try again in a few minutes.

https://edge.churchless.tech/edgesvc/turing/conversation/create ```

Additional information

No response

Seminko commented 1 year ago

FYI - still not fixed.

acheong08 commented 1 year ago

HTML being printed is intended for debug purposes

Seminko commented 1 year ago

Would be great if there was an option to turn if off.

Meshwa428 commented 1 year ago

You should probably use the latest python version 3.11.3

Because the error isn't happening in it

linxing314 commented 1 year ago

When printing HTML page into console, it also throws an "Exception: Authentication failed".

I think my cookies has been expired, but when I relogin my account in Edge and Chrome and get the new cookies, this problem remains. It has been 3 days since this bug occured and it's still not fixed even I updat EdgeGPT and python to the latest version. After reviews the code, I find that it returned 502 when accessing https://edge.churchless.tech/edgesvc/turing/conversation/create

acheong08 commented 1 year ago

The fallback proxy is dead

SnappsiSnappes commented 1 year ago

im solved it using proxy generator, look at my repository - Jarvis voice assistant :) shortly saying : 1) pip install proxybroker2 2) creating file proxies.txt and adding 10 ip proxy to it

def proxy_file():
    import asyncio
    from proxybroker import Broker
    async def save(proxies, filename):
        """Save proxies to a file."""
        with open(filename, 'w') as f:
            while True:
                proxy = await proxies.get()
                if proxy is None:
                    break
                f.write('%s:%d\n' % (proxy.host, proxy.port))

    def main():
        proxies = asyncio.Queue()
        broker = Broker(proxies)
        tasks = asyncio.gather(broker.grab(countries=['US', 'GB'], limit=10),
                            save(proxies, filename='proxies.txt'))
        loop = asyncio.get_event_loop()
        loop.run_until_complete(tasks)
    main()

if __name__ == '__main__':
    proxy_file()

3)

def read_proxies(filename='proxies.txt'):
    '''
read proxies , return list with ['http://123:89'] # prefix http
    '''
    with open(filename, 'r') as f:
        lines = f.readlines()
    proxies = ['http://' + line.strip() for line in lines if line.strip()]
    return proxies

if __name__ =='__main__':
    proxies = read_proxies('proxies.txt')
    print(proxies)

4) something like this

    def proxy_start_bot():
        global bot
        for proxy in proxy_list:
            try:
                bot = Chatbot(cookie_path='cookies.json', proxy=proxy)

                break
            except Exception as e:
                print(f"error  {proxy}: {e}")

proxy_list = read_proxies() proxy_start_bot() ... hope you got the idea 😊 p.s. im using EdgeGPT==0.2.0