EvanZhouDev / bard-ai

A lightweight library to access Google Bard.
https://www.npmjs.com/package/bard-ai
GNU General Public License v3.0
117 stars 31 forks source link

Error !! #36

Closed Jucamhc closed 1 year ago

Jucamhc commented 1 year ago

/bard-ia/node_modules/bard-ai/index.js:29 else throw new Error("Could not get Google Bard."); ^

kevindevm commented 1 year ago

same

ThatXliner commented 1 year ago

Duplicate of https://github.com/EvanZhouDev/bard-ai/issues/31

Jucamhc commented 1 year ago

/node_modules/bard-ai/index.js:29 else throw new Error("Could not get Google Bard."); ^

           with version "bard-ai": "^1.5.4", same
EvanZhouDev commented 1 year ago

I've heard that this may be because your account should be using another cookie... this feature will be implemented in v2. Please hold on...

thisago commented 1 year ago

Yes, now the needed cookies are: __Secure-1PSID and __Secure-1PSIDTS

See my working implementation: https://github.com/thisago/bard/blob/master/src/bard.nim#L76

But the __Secure-1PSIDTS expires so fast, then I made this lib to workaround this: https://github.com/thisago/gookie

EvanZhouDev commented 1 year ago

Hmm... looks like they're forcing us to use the PaLM API... time to migrate I guess...

thisago commented 1 year ago

for what I want. my dirty workaround works well, but for larger projects, an api is better; but migrating to an paid API is very divergent from an open source lib that uses the internal API for free

EvanZhouDev commented 1 year ago

~I know. But the bigger question: How does Google do it (and why can't we do it)?~

EDIT: That was a silly question...

thisago commented 1 year ago

how they make harder the use of internal API?

EvanZhouDev commented 1 year ago

Use of __Secure-1PSIDTS is coming in version 2... I've heard that if you don't refresh the bard.google.com page, it doesn't change the key, so that might be a solution?

Either way, stay tuned to #30, the Feature Tracker for version 2. I'll be closing this, but feel free to reopen.

thisago commented 1 year ago

With my tests, with my cli bard app, some times the session expires, but this app can regain with my dirty workaround. I'll test more.

thisago commented 1 year ago

Also, I tested getting the __Secure-1PSIDTS cookie, getting SNlM0e (with lib) and refreshing a google bard page in browser and session still works, I think that it expires with time

thisago commented 1 year ago

I tested by 1 hour and 40 minutes with same session and it didn't expired

EvanZhouDev commented 1 year ago

There's no way for it to expire on the same session, I don't think. Setting a timer for cookie expiration seems like a bad idea 😅.