Amm1rr / WebAI-to-API

Claude, Gemini to API : ) (Don't need API KEY)
MIT License
194 stars 39 forks source link

Bard response: {"Error":"Check the Bard session."} #7

Closed johnd0e closed 10 months ago

johnd0e commented 10 months ago

In server console: Error: Session not found.

SESSION_ID and SESSION_IDTS are set in Config.conf

Note: I have usually several logon sessions, but i tried all cookies with no success (such as __Secure-3PSID)

P.S. I was testing with curl. But example_bard.py works..

johnd0e commented 10 months ago

Fixed by changing "session_id": "session-ID" to "session_id": ""

Amm1rr commented 10 months ago

Yes, it's not clear. I will make the necessary changes. Thank you for bringing this to my attention.

Also, Bard had another recent change that requires updating the cookie with one more value. I have made the update and will submit a pull request soon.

Update: Fixed

johnd0e commented 10 months ago

Fixed

Now I see "Error: Session not found" in server's console only. But request (curl) just returns without any message - I do not think that it is good.

And the most important - it is not clear why we may need to specify the value already present in Config.conf?

It would be more useful to have ability to continue some previous conversation, specifying it's id.

Amm1rr commented 10 months ago

The Bard session configuration has changed. Now there need to be 3 cookies configured in the Config.conf file Bard section. Make sure to include:

Name Session Name
session_id __Secure-1PSID
session_idts __Secure-1PSIDTS
session_idcc __Secure-1PSCC

Originally I used this webserver with different cookies, but I understand what you mean, I will change it.

johnd0e commented 10 months ago

BTW, I do not know how, but atm Bard in https://github.com/xtekky/gpt4free works without specifying any cookie!

Amm1rr commented 10 months ago

Actually, it's the 'browser_cookie3' library that I used as well. Have a look How to Usage.

You can use Claude and Bard by simply logging into your browser session. However, it can be tricky because if you log in to different browsers (Chrome, Firefox, Safari...) or profiles, they may get confused about the correct sessionKey.

By the way, it will need more time to become stable.

Just remember, you should set an empty SessionKey value in the Config file.

johnd0e commented 10 months ago

With empty Config I can use Claude. But not Bard. In the same environment, with gpt4free I can use Bard.

Here is my setup:

Amm1rr commented 10 months ago

They set up all cookies for google. and it's working. And I tried to make a filter to catch the correct cookie. It seems there is no need to filter cookies.

I'm still traveling, I would soon fix it.

Amm1rr commented 10 months ago

Pull request, it should work now with login by browser. Keep me update please.

johnd0e commented 10 months ago
  File "D:\AI\WebAI-to-API\src\main.py", line 340, in ask_bard
    chatbot = ChatbotBard(cookies)
NameError: name 'cookies' is not defined
Amm1rr commented 10 months ago

I fixed those and also removed sessionID as a parameter.

If the config file is empty, Bard will try to find the browser session key.

Pull request, please

johnd0e commented 10 months ago

IndentationError: unexpected indent https://github.com/Amm1rr/WebAI-to-API/blob/b2476425af34f5ded6edae1911e1a26c85899565/src/main.py#L319-L320

NameError: name '_cookies' is not defined: https://github.com/Amm1rr/WebAI-to-API/blob/b2476425af34f5ded6edae1911e1a26c85899565/src/main.py#L846

Amm1rr commented 10 months ago

Oops! pull request, plz

johnd0e commented 10 months ago

Success!