acheong08 / EdgeGPT

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

[Bug]: Exception: CaptchaChallenge: User needs to solve CAPTCHA to continue. #586

Open a37836323 opened 1 year ago

a37836323 commented 1 year ago

Is there an existing issue for this?

What happened?

After using it 30 times, it prompts this, what should I do?

Steps to reproduce the problem

  1. After using it 30 times, it prompts this, what should I do?

What should have happened?

After using it 30 times, it prompts this, what should I do?

Version where the problem happens

3.9

What Python version are you running this with?

3.9

What is your operating system ?

Linux

Command Line Arguments

no

Console logs

Traceback (most recent call last):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 31, in chat
    responses = loop.run_until_complete(get_responses())
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 18, in get_responses
    async for final, response in bot.ask_stream(prompt=question, conversation_style=ConversationStyle.creative):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/EdgeGPT.py", line 185, in ask_stream
    async for response in self.chat_hub.ask_stream(
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/chathub.py", line 197, in ask_stream
    raise Exception(
Exception: CaptchaChallenge: User needs to solve CAPTCHA to continue.
[2023-07-02 01:31:19,185] ERROR in app: Exception on /chat [POST]
Traceback (most recent call last):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 31, in chat
    responses = loop.run_until_complete(get_responses())
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 18, in get_responses
    async for final, response in bot.ask_stream(prompt=question, conversation_style=ConversationStyle.creative):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/EdgeGPT.py", line 185, in ask_stream
    async for response in self.chat_hub.ask_stream(
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/chathub.py", line 197, in ask_stream
    raise Exception(
Exception: CaptchaChallenge: User needs to solve CAPTCHA to continue.

Additional information

ok

kang121209 commented 1 year ago

mee too

Meshwa428 commented 1 year ago

Same here, when ever i try to create a new conversation it shows this error

Traceback (most recent call last):
  File "p:\Python\J.A.R.V.I.S\Jarvis Using Python\Brain\Qna.py", line 63, in <module>
    name = Qna()
           ^^^^^
  File "p:\Python\J.A.R.V.I.S\Jarvis Using Python\Brain\Qna.py", line 60, in Qna
    app = asyncio.run(Starting_prompt(data))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\vandu\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\vandu\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\vandu\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete        
    return future.result()
           ^^^^^^^^^^^^^^^
  File "p:\Python\J.A.R.V.I.S\Jarvis Using Python\Brain\Qna.py", line 40, in Starting_prompt
    response = await bot1.ask(prompt=prompt, conversation_style=ConversationStyle.creative, simplify_response=True)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\vandu\AppData\Local\Programs\Python\Python311\Lib\site-packages\EdgeGPT\EdgeGPT.py", line 116, in ask
    async for final, response in self.chat_hub.ask_stream(
  File "C:\Users\vandu\AppData\Local\Programs\Python\Python311\Lib\site-packages\EdgeGPT\chathub.py", line 197, in ask_stream      
    raise Exception(
Exception: CaptchaChallenge: User needs to solve CAPTCHA to continue.
Eikosa commented 1 year ago

I solve this problem by using a proxy

adekability commented 1 year ago

I solve this problem by using a proxy

@Eikosa , hello! Which country did you use as a proxy server location?

Eikosa commented 1 year ago

I solve this problem by using a proxy

@Eikosa , hello! Which country did you use as a proxy server location?

I try with the https://pypi.org/project/free-proxy/ module until I find a suitable https proxy, one of them always works

Meshwa428 commented 1 year ago

Is it possible to create a captcha solver, so that we don't have to use a proxy, by the way there is another way to solve this issue. Before running your script you can just go to bing.com/chat and then it will automatically solve the captcha, then you can run your script, and it will work as good as new

acheong08 commented 1 year ago

What does the captcha look like? Is it arkose/funcaptcha? I haven't triggered it yet so can't fix. If it is indeed arkose/funcaptcha, I got it reversed at https://github.com/acheong08/funcaptcha

YonQua commented 1 year ago
WechatIMG202

User needs to solve CAPTCHA to continue.

Eikosa commented 1 year ago

I'm sorry to say that using a proxy doesn't seem to solve this problem anymore

lovelf commented 1 year ago

Many verification codes have been encountered,A headache problem

DreamMaoMao commented 1 year ago

Has there been any progress on this issue

plageon commented 1 year ago

also met this problem

wangyu1997 commented 1 year ago

me too

mayuqianjg commented 1 year ago

Me three

ProfDrLuigi commented 1 year ago

Me four

Qewertyy commented 1 year ago

Me five

wangyu1997 commented 1 year ago

Interesting。。。

DrowskoytayhulGuider commented 1 year ago

Interesting。。。

I want to ask how do you use it? I always got a problem: raise TooManyRedirects( httpx.TooManyRedirects: Exceeded maximum allowed redirects.

wangyu1997 commented 1 year ago

Interesting。。。

I want to ask how do you use it? I always got a problem: raise TooManyRedirects( httpx.TooManyRedirects: Exceeded maximum allowed redirects.

You can use a us proxy or directly deploy on a us machine

DrowskoytayhulGuider commented 1 year ago

Interesting。。。

I want to ask how do you use it? I always got a problem: raise TooManyRedirects( httpx.TooManyRedirects: Exceeded maximum allowed redirects.

您可以使用美国代理或直接部署在美国计算机上

You mean I need to get a valid US proxy IP and add it in "--proxy" parameter? I have to build a proxy pool?

nacho00112 commented 1 year ago

The free-proxy library give proxies but they doesn't worked for me:

from EdgeGPT.EdgeGPT import Chatbot
from fp.fp import FreeProxy

import json, asyncio

async def main():
    proxy = FreeProxy().get()
    cookies = json.load(open("cookies.json"))
    bot = Chatbot.create(cookies=cookies, proxy=proxy)
    response = await bot.ask(prompt="hello")
    print(response)
if __name__ == "__main__":
    asyncio.run(main())

I get SSL Verification failed or Captcha error

Eikosa commented 1 year ago

The free-proxy library give proxies but they doesn't worked for me:

from EdgeGPT.EdgeGPT import Chatbot
from fp.fp import FreeProxy

import json, asyncio

async def main():
    proxy = FreeProxy().get()
    cookies = json.load(open("cookies.json"))
    bot = await Chatbot.create(cookies=cookies, proxy=proxy)
    response = bot.ask(prompt="hello")
    print(response)
if __name__ == "__main__":
    asyncio.run(main())

I get SSL Verification failed or Captcha error

use freeproxy with https, it is unlikely, but sometimes it works

DrowskoytayhulGuider commented 1 year ago

The free-proxy library give proxies but they doesn't worked for me:

from EdgeGPT.EdgeGPT import Chatbot
from fp.fp import FreeProxy

import json, asyncio

async def main():
    proxy = FreeProxy().get()
    cookies = json.load(open("cookies.json"))
    bot = await Chatbot.create(cookies=cookies, proxy=proxy)
    response = bot.ask(prompt="hello")
    print(response)
if __name__ == "__main__":
    asyncio.run(main())

I get SSL Verification failed or Captcha error

When I use free proxies, I often get SSL Verification failed, too. And sometimes I also get "all connections failed." and "connectError"

DrowskoytayhulGuider commented 1 year ago

I tried many free proxies, but all didn't work.

watashihame commented 1 year ago

I'm using gpt_academic and I met the same problem. My solution is modified the user-agent and other information showed in this file. You can try the instruction below:

  1. Using the exactly same header as your browser (Mircrosoft edge), including user-agent and browser version informaiton.
  2. Using your code to ask any question (normally you will get the exception as this issue said).
  3. Using your browser to ask any question with new bing (manually solve the captcha).
  4. Free to use your code to ask with new bing.
tianlichunhong commented 1 year ago

I have the same problem.The only temporary fix I can come up with at the moment is to log in and visit new bing via the edge browser, and click the CAPTCHA. This can let my edgeGPT work for one day.

Meshwa428 commented 1 year ago

same i have to do this process before running the script and it lets me use it for 1 day, just open edge browser and then solve the captcha it manualy, and then it lets me do the job done

ustedestaaqui commented 1 year ago

same i have to do this process before running the script and it lets me use it for 1 day, just open edge browser and then solve the captcha it manualy, and then it lets me do the job done

But when I open the browser no captcha appears

ustedestaaqui commented 1 year ago

I have the same problem.The only temporary fix I can come up with at the moment is to log in and visit new bing via the edge browser, and click the CAPTCHA. This can let my edgeGPT work for one day.

But when I open the browser no captcha appears

tianlichunhong commented 1 year ago

I have the same problem.The only temporary fix I can come up with at the moment is to log in and visit new bing via the edge browser, and click the CAPTCHA. This can let my edgeGPT work for one day.

But when I open the browser no captcha appears

You need to ask a question, then you can see the captcha.

ustedestaaqui commented 1 year ago

but when I enter from the web it does not ask me for any captcha, I can chat normally

Meshwa428 commented 1 year ago

Then you are good to go, you can run your script

nacho00112 commented 1 year ago

Might be this error is related with VPNs, you used a VPN?

ProfDrLuigi commented 1 year ago

If you are running a Linux Desktop Environment I solved it now this way. Install Microsoft Edge and xdotool. Start Edge, log into your M$ Account and select saving the credentials for future browser starts. If done you can now execute this snippet here automatic via cron once or twice a day.

/usr/bin/microsoft-edge-stable %U "https://www.bing.com/search?q=Hi+Bot&showconv=1&FORM=hpcodx&sydconv=1&scdexwlcs=1&scdexwlispw=1&sendquery=1" && sleep 10 && xdotool key ctrl+w"

It starts the Edge Browser, sends "Hi Bot" to the Bot and the Verification capture is done and the Browser quits automatic. Et voila you can now use edgegpt again for the next 24h. :)

Meshwa428 commented 1 year ago

Thanks for the help, but we windows users have to do that stuff manualy or in WSL, i think automating it with selenium might be a good idea, I mean we can use selenium to automate edge browser. Just log in to it, send a hi to bing and done. I am starting to work on it, after i complete i will provide the code snippet here

ustedestaaqui commented 1 year ago

Thanks for the help, but we windows users have to do that stuff manualy or in WSL, i think automating it with selenium might be a good idea, I mean we can use selenium to automate edge browser. Just log in to it, send a hi to bing and done. I am starting to work on it, after i complete i will provide the code snippet here

I was trying to program it in selenium but I couldn't do the code with bing hahaha

phamxtien commented 1 year ago

I fix it by request to https://www.bing.com/turing/conversation/create and get conversationSignature import requests and add newlines

image

nacho00112 commented 1 year ago

I fix it by request to https://www.bing.com/turing/conversation/create and get conversationSignature import requests and add newlines

image

Then please make the PR

nacho00112 commented 1 year ago

I checked Conversation and it already makes that request and set struct to the whole json but uses a different url: https://edgeservices.bing.com/edgesvc/turing/conversation/create

ProfDrLuigi commented 1 year ago

I fix it by request to https://www.bing.com/turing/conversation/create and get conversationSignature import requests and add newlines

Doesn´t work here.

phamxtien commented 1 year ago

Today, I got 503, I back to previous code (remove https://www.bing.com/turing/conversation/create) and it runs smooth

phamxtien commented 1 year ago

Now it requires CAPTCHA :(

phamxtien commented 1 year ago

I am not sure but after change lines 20, 21 in constant.py to "sec-ch-ua-full-version": '"116.0.1938.27"', "sec-ch-ua-full-version-list": '"Chromium";v="116.0.5845.42", "Not)A;Brand";v="24.0.0.0", "Microsoft Edge";v="116.0.1938.27"',

image

and it runs smooth.

phamxtien commented 1 year ago

Fix it with

def getCookies(url):
    import browser_cookie3
    browsers = [
        # browser_cookie3.chrome,
        # browser_cookie3.chromium,
        # browser_cookie3.opera,
        # browser_cookie3.opera_gx,
        # browser_cookie3.brave,
        browser_cookie3.edge,
        # browser_cookie3.vivaldi,
        # browser_cookie3.firefox,
        # browser_cookie3.librewolf,
        # browser_cookie3.safari,
    ]
    for browser_fn in browsers:
        # if browser isn't installed browser_cookie3 raises exception
        # hence we need to ignore it and try to find the right one
        try:
            cookies = []
            cj = browser_fn(domain_name=url)
            for cookie in cj:
                cookies.append(cookie.__dict__)
            return cookies
        except:
            continue

and

bot = EdgeGPT.Chatbot(cookies=getCookies('.bing.com'))
Meshwa428 commented 1 year ago

thanks

Meshwa428 commented 1 year ago

is acheong still fixing this issue or he isn't

leez7one commented 1 year ago

Thanks for the help, but we windows users have to do that stuff manualy or in WSL, i think automating it with selenium might be a good idea, I mean we can use selenium to automate edge browser. Just log in to it, send a hi to bing and done. I am starting to work on it, after i complete i will provide the code snippet here

Any updates ?

cousintiz commented 1 year ago

Is there an existing issue for this?

  • [ ] I have searched the existing issues and checked the recent builds/commits

What happened?

After using it 30 times, it prompts this, what should I do?

Steps to reproduce the problem

  1. After using it 30 times, it prompts this, what should I do?

What should have happened?

After using it 30 times, it prompts this, what should I do?

Version where the problem happens

3.9

What Python version are you running this with?

3.9

What is your operating system ?

Linux

Command Line Arguments

no

Console logs

Traceback (most recent call last):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 31, in chat
    responses = loop.run_until_complete(get_responses())
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 18, in get_responses
    async for final, response in bot.ask_stream(prompt=question, conversation_style=ConversationStyle.creative):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/EdgeGPT.py", line 185, in ask_stream
    async for response in self.chat_hub.ask_stream(
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/chathub.py", line 197, in ask_stream
    raise Exception(
Exception: CaptchaChallenge: User needs to solve CAPTCHA to continue.
[2023-07-02 01:31:19,185] ERROR in app: Exception on /chat [POST]
Traceback (most recent call last):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/flask/app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 31, in chat
    responses = loop.run_until_complete(get_responses())
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/www/wwwroot/ceshi701/EdgeGPT/bbb.py", line 18, in get_responses
    async for final, response in bot.ask_stream(prompt=question, conversation_style=ConversationStyle.creative):
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/EdgeGPT.py", line 185, in ask_stream
    async for response in self.chat_hub.ask_stream(
  File "/www/wwwroot/ceshi701/EdgeGPT/7815696ecbf1c96e6894b779456d330e_venv/lib/python3.9/site-packages/EdgeGPT/chathub.py", line 197, in ask_stream
    raise Exception(
Exception: CaptchaChallenge: User needs to solve CAPTCHA to continue.

Additional information

ok

having the same problem

Meshwa428 commented 1 year ago

Thanks for the help, but we windows users have to do that stuff manualy or in WSL, i think automating it with selenium might be a good idea, I mean we can use selenium to automate edge browser. Just log in to it, send a hi to bing and done. I am starting to work on it, after i complete i will provide the code snippet here

Any updates ?

Trying it. still figuring out that how does their captcha work. If any one knows that what kind of captcha it is, can you please tell it to me so that it would be easier to solve this problem

Meshwa428 commented 1 year ago

SC Guys, I found out that bing shows this captcha when it asks user to solve it. Any clues on how to solve it using python, Anyone??