vsakkas / sydney.py

Python Client for Copilot (formerly named Bing Chat), also known as Sydney.
MIT License
263 stars 37 forks source link

Error : Failed to create conversation, received status: 404 #109

Closed IKDH closed 10 months ago

IKDH commented 10 months ago

Hello,

I have this error since few hours : Error : Failed to create conversation, received status: 404.

After few retry, it is working. But the error appear frequently.

vsakkas commented 10 months ago

Hi @IKDH

I will take a look thanks for reporting. Looks like this shows up occasionally for other users as well.

(I wonder if it is related to the recent move to Copilot from Bing Chat and things are changing internally)

IKDH commented 10 months ago

It's probably that !

vsakkas commented 10 months ago

Hi @IKDH I haven't really been able to reproduce this issue. Does it still happen to you? Perhaps it is region dependent..

If it continues to occur, perhaps try a workaround: Change the URL used to start a conversation by replacing this value with this: https://edgeservices.bing.com/edgesvc/turing/conversation/create?bundleVersion=1.1359.6

It's the URL used by the sidebar instead of the main web page.

IKDH commented 10 months ago

Hello, it's not happening anymore.

Does the library will still work when Microsoft will fully migrate to https://copilot.microsoft.com/ ?

vsakkas commented 10 months ago

Good to know that it is not occurring anymore. Seems like that it's some occasional server side issue. A good retry mechanism should be able to deal with it.

To answer your questions, there is no way to know what will happen. So far the API is the same and you can even use the _U cookie from the new https://copilot.microsoft.com/ web page! If the API changes in some way, I will try to update Sydney.py to make it compatible :muscle:

(I also set up recently weekly test runs, so catching API breaking changes should be easier to do so!)

IKDH commented 10 months ago

Thank you for your amazing job !

Some people are able to use this library without cookie in some regions. Is it related to the fact to be able to use Bing Chat without being connected on a Microsoft account ? Because I can use Bing Chat without being connected using the the Microsoft UI but everytime I try to use the librabry without a cookie, I get a captcha.

vsakkas commented 10 months ago

Hm, different regions certainly have different results. For example, the automated tests on Github don't use a cookie anymore, but I get Captcha errors every time I try to do the same on my local machine!

Regarding not being able to use with a cookie, I can think of a few things that you may or may not have tried:

IKDH commented 10 months ago

I can use it with a cookie. No problem with that.

But I can't without a cooki and I am wondering why because I can use it without a cookie with the Microsoft interface of Bing chat. I will try with a residential proxy and see if it solves the problem.

vsakkas commented 10 months ago

I suspect that might be a region issue, similar to what I am facing. I am continuing work on making everything be as consistent as possible with what happens on the browser, but there is no guarantee that it's enough to fix this :thinking:

IKDH commented 10 months ago

Even with cookie, something is different with the library because, if i create a new cookie and I use the browser, it is working without captcha. Then, if I use the library, it will trigger a captcha that can be solved with the browser. If I solve it with the browser, I can then use the library (it's the pattern you have described above).

It means that some things are missing to reproduce the exact behavior of the browser.

vsakkas commented 10 months ago

Indeed, something is missing. I can see that the conversation ID made with Sydney contains the string BingProdUnAuthenticatedUsers while if you do the same while logged in on Edge you get BingProd, so somehow the Bing Chat server can detect some difference even when using the _U cookie!

Well, I will continue to investigate that, would be nice to get it fixed

vsakkas commented 10 months ago

@IKDH This seems very promising

IKDH commented 10 months ago

I will try. Have you updated the README ? I was using this to give the cookie to the script : os.environ["BING_U_COOKIE"] =

How do you do now ? You give it the path of a JSON file with the entire cookie ?

vsakkas commented 10 months ago

The documentation is not updated yet, will do so before merging it though!

So the way it works, is that you go to the network tab, find the create request to https://www.bing.com/turing/conversation/create?bundleVersion=1.1342.3-cplt.7, cope the entire cookie section and then set it an environment variable, named BING_COOKIES.

I don't see a way to copy all cookies from the application page without relying on extensions, which is a bit unfortunate.

IKDH commented 10 months ago

There are lot of extension which allow you to do it easily ! I have already used library where you paste your cookie on a JSON file and you call it on your script.

vsakkas commented 10 months ago

Indeed, there are, although for now I'd rather avoiding recommending a specific extension!

vsakkas commented 10 months ago

I haven't seen any 404 issues recently, so looks like it's a temporary issue. Closing this one.