Bard-API
Bard-API copied to clipboard
Large volume of requests may result in a ban
I was throwing a request to Bard to summarize a paper, and it started throwing Response Error halfway through. This happens regardless of the Token and will not accept requests from python. Requests from web browsers are successfully accepted, so there may be some way to fix this. Do you have any ideas?
Response Error: b')]}\'\n\n38\n[["wrb.fr",null,null,null,null,[8]]]\n55\n[["di",90],["af.httprm",89,"-5846312931853295462",1]]\n25\n[["e",4,null,null,130]]\n'.
Is it correct that you have confirmed that responses are generated for short texts like "hi"? For testing, try passing a generous timeout value to the Bard class.
Bard(timeout=200).get_answer("large Input text ")
Yes, And I think it has to do with the total amount sent from python so far, not the length. I used to be able to communicate with bard normally, but suddenly they started sending back only Response Error. I have the Timeout set to 512 and I get a ResponseError immediately.
from bardapi import Bard
import os
import requests
import os
os.environ['_BARD_API_KEY']="MyToken"
session = requests.Session()
session.headers = {
"Host": "bard.google.com",
"X-Same-Domain": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"Origin": "https://bard.google.com",
"Referer": "https://bard.google.com/",
}
session.cookies.set("__Secure-1PSID", os.getenv("_BARD_API_KEY"))
# session.cookies.set("__Secure-1PSID", token)
bard = Bard(session=session, timeout=512)
# Continued conversation without set new session
bard.get_answer("hello")['content']
Bard(timeout=256).get_answer('hello')['content']
ResponseError occurred for both patterns.
One thing I do know is that if I run this on another computer, the error goes away. Maybe it is restricted by IP address.
One thing I do know is that if I run this on another computer, the error goes away. Maybe it is restricted by IP address.
Recently, I confirmed that the cookie value is initialized even during use, and added it to the readme. Isn't the cookie value initialized during use?
It is unlikely that your IP is blocked. Because if the IP is blocked, you should not receive a proper response even on the web.
The issue has been resolved, so I'm closing it. If you happen to identify the exact cause, I would appreciate it if you could share it. Thank you.
Only the computer was changed and the cookie values were executed identically. The Response Error still occurs there. After about 10 hours from the time the Response Error was confirmed, I ran the program again from the same computer, and the conversation succeeded even with the same cookie. Frequency may have something to do with it.
Caution!
Please be aware that using this Python package carries certain risks and considerations. Here are some important points to keep in mind:
-
Not an Official Google Package: This package is not developed or maintained by Google. It is an unofficial implementation created to support developers in testing functionalities. As a result, it may not have the same level of reliability, support, or security as an official package.
-
No API Service: This package does not provide an API service. It should not be treated as a production-ready solution for commercial purposes. Its primary purpose is to assist with functional testing and experimentation.
-
Google Account Limitations: The package utilizes cookie values associated with a Google account. Excessive or abusive usage, particularly for commercial purposes, may lead to restrictions or limitations being imposed on your Google account. It is crucial to use this package responsibly and within the bounds of Google's terms of service.
-
Delayed Updates: Since this package is not officially supported by Google, it may experience delays in updates or compatibility with the latest Google services. Dependencies on Google services should be regularly monitored and updated to ensure proper functioning.
-
Readme Information: The cautionary details mentioned here have also been documented in the Readme file to ensure that users are well-informed about the nature and limitations of this package.
Please exercise caution and use this package responsibly.
I think the token expires, i got this same error but i visited the bard website and saw a new token and used it.
I think the token expires, i got this same error but i visited the bard website and saw a new token and used it.
I also saw that the token changes constantly. it would be interesting if we develop a way to update the token whenever it changes
As the frequency of cookie changes has increased. I merged some idea commit. #12
erickythierry If you have any ideas for an automated method, I would greatly appreciate your contribution. Once you create a pull request, I will gladly test the functionality and merge it accordingly. However, please keep in mind that achieving global functionality may present certain challenges.
The cookie is ok for 12 days, even when it changes via browser. Calling it too much and too frequently will result in a temporary ban