Git Product home page Git Product logo

Comments (15)

lamebrain0 avatar lamebrain0 commented on June 10, 2024 4

@SPomodor please provide a more explantion..it will be very valuaeable.

from bard-api.

OlegRuban-ai avatar OlegRuban-ai commented on June 10, 2024 1

@dsdanielpark

thanks, it worked. For some reason it works in combination with __Secure-ENID, I continue testing

from bard-api.

bhavik-malhotra avatar bhavik-malhotra commented on June 10, 2024

Same problem, no longer able to generate responses even after updating to bardapi==0.1.39

from bard-api.

dsdanielpark avatar dsdanielpark commented on June 10, 2024

Consider passing at least 3 cookie values. https://github.com/dsdanielpark/Bard-API/blob/main/documents/README_DEV.md#multi-cookie-bard

from bard-api.

mathisen99 avatar mathisen99 commented on June 10, 2024

@dsdanielpark Yes i looked into that, but the code example want the second cookie to be " __Secure-1PSIDTS " value but that cookie does not exist anymore.
If you look at the image i have attached to the main issue that is all cookies that exists now.

from bard-api.

dsdanielpark avatar dsdanielpark commented on June 10, 2024

mathisen99
Some users have reported that the cookie value does not end with a single dot, but there have been no additional issues.

Firstly, try experimenting with different cookie values to find a method that works correctly. Alternatively, you could use a VPN to bypass and set it to a different country or region, or try changing the nationality of the google account. Recently, Google seems to be taking a tough stance on bypassing with VPNs or changing countries, especially regarding YouTube Premium or other Google Cloud Services.

I apologize for the difficulty in debugging or finding a solution directly, as I cannot reproduce the error myself.

Unfortunately, there are no other ways I can help, except for developers facing similar challenges to find and share workarounds. As mentioned in the FAQ or README, sadly, the Bard-API package is an unofficial package and may become unusable at any time.

I will keep this issue open. Thank you.

from bard-api.

OlegRuban-ai avatar OlegRuban-ai commented on June 10, 2024

same problem, IP from Ukraine, Bard 0.1.38, but doesn’t work with 0.1.39 either, the cookie file requires it to end with .

from bard-api.

dsdanielpark avatar dsdanielpark commented on June 10, 2024

OlegRuban-ai

The message stating that it should end with a single dot in 0.1.39 version is merely a print statement for testing purposes, not an asset. You should pay attention to the next error message following this statement.

from bard-api.

dsdanielpark avatar dsdanielpark commented on June 10, 2024

OlegRuban-ai
What a nice.

I hope you find it! Please share with the other users.

from bard-api.

SPomodor avatar SPomodor commented on June 10, 2024

@dsdanielpark
Hi, I noticed that all the same cookies are needed to work (__Secure-1 PSID and __Secure-1PSIDTS). If you log in separately via selenium using these cookies, everything will work fine

from bard-api.

dsdanielpark avatar dsdanielpark commented on June 10, 2024

New documentation have been made for new args.

from bard-api.

hh-at-of avatar hh-at-of commented on June 10, 2024

After patching the library by removing the check if the __Secure-1PSID cookie ends with a dot in bardapi/core.py (line 173) and bardapi/utils.py (line 106) the following code works for me (with firefox as browser)

from bardapi import Bard

bard = Bard(token_from_browser=True, multi_cookies_bool=True)
bard.get_answer("What is Bard?")

from bard-api.

lamebrain0 avatar lamebrain0 commented on June 10, 2024

it is working..But how to use bard api on a linux server having no web browser ..maybe i sounds stupid.

from bard-api.

aniruddhkrish avatar aniruddhkrish commented on June 10, 2024

I have found the solution for this.

But I think this only works with Firefox browser.

Here are the steps to use the latest Gemini AI through Bardapi with some kind of stability.

Install Firefox.

Sign in to Gemini (formerly Bard) with your google account credentials.

Unzip the updated files which are attached here and place it in the appropriate folders

Then you will be able to use bardapi seamlessly with the following code. Every time you run this code, it will extract the new cookies from firefox and send it to bardapi.
Make sure to pip install browser_cookie3.

import requests
from bardapi import SESSION_HEADERS, BardCookies
import browser_cookie3

domain = '.google.com'

firefox_cookies = browser_cookie3.firefox(domain_name=domain)

psid = '__Secure-1PSID'
dts = '__Secure-1PSIDTS'
dcc = '__Secure-1PSIDCC'
nid = 'NID'

psid_value = None
dts_value = None
dcc_value = None
nid_value = None

for cookie in firefox_cookies:
    if cookie.name == psid:
        psid_value = cookie.value
    elif cookie.name == dts:
        dts_value = cookie.value
    elif cookie.name == dcc:
        dcc_value = cookie.value
    elif cookie.name == nid:
        nid_value = cookie.value


cookie_dict = {
    "__Secure-1PSID": psid_value,
    "__Secure-1PSIDTS": dts_value,
    "__Secure-1PSIDCC": dcc_value,
}
session = requests.Session()
session.cookies.set("__Secure-1PSID", psid_value)
session.cookies.set( "__Secure-1PSIDCC", dcc_value)
session.cookies.set("__Secure-1PSIDTS", dts_value)
session.cookies.set("NID",nid_value)
session.headers = SESSION_HEADERS

bard = BardCookies(session=session,cookie_dict=cookie_dict)

while True:

    question = input("Enter your prompt to Gemini: ")
    response = bard.get_answer(question)['content']
    data = str(response).replace("*", "")
    print(data)
    

Updated files.zip

from bard-api.

dsdanielpark avatar dsdanielpark commented on June 10, 2024

[NOTICE] Please, go to Gemini-API https://github.com/dsdanielpark/Gemini-API

Gemini Icon Google - Gemini API

A unofficial Python wrapper, python-gemini-api, operates through reverse-engineering, utilizing cookie values to interact with Google Gemini for users struggling with frequent authentication problems or unable to authenticate via Google Authentication.

Collaborated competently with Antonio Cheong.

What is Gemini?

[Paper] [Official Website] [Official API] [API Documents]

Gemini is a family of generative AI models developed by Google DeepMind that is designed for multimodal use cases. The Gemini API gives you access to the Gemini Pro and Gemini Pro Vision models. In February 2024, Google's Bard service was changed to Gemini.


Installation

pip install python-gemini-api
pip install git+https://github.com/dsdanielpark/Gemini-API.git

For the updated version, use as follows:

pip install -q -U python-gemini-api

from bard-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.