Amm1rr/WebAI-to-API

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

johnd0e opened this issue · 14 comments

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..

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

Amm1rr commented

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

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

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.

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

Amm1rr commented

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.

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

Here is my setup:

  • I have Edge, Firefox and Chrome installed
  • I am logged in Edge (only), both in Bard and Claude.
Amm1rr commented

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

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

  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

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

IndentationError: unexpected indent

WebAI-to-API/src/main.py

Lines 319 to 320 in b247642

session_name = "Bard" if sessionId == "SESSION_ID" else ("BardTS" if sessionId == "SESSION_DTS" else "BardCC")
sess_id = get_Cookie(session_name)

NameError: name '_cookies' is not defined:

if cookie_domain not in _cookies:

Amm1rr commented

Oops!
pull request, plz

Success!