dsdanielpark / Bard-API

The unofficial python package that returns response of Google Bard through cookie value.

Home Page:https://pypi.org/project/bardapi/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'BardAsync' object has no attribute 'SNlM0e' after update to latest version at github

ahmadkeren opened this issue · comments

my code:

bard = BardAsync(token=tokenBard)
jawaban = await bard.get_answer(q)

previously it was running normally before I updated the version

i rollback to version 0.1.30. everything working fine

i rollback to version 0.1.30. everything working fine

confirmed this worked.

We are currently overhauling bard async on the GitHub dev version. It will be a bit more organized in version 0.1.39.
It can currently be partially checked on the GitHub dev version.
The synchronous version is still somewhat unstable (as it hasn't been properly optimized), so we recommend using the regular bard. Thank you.

We are currently overhauling bard async on the GitHub dev version. It will be a bit more organized in version 0.1.39. It can currently be partially checked on the GitHub dev version. The synchronous version is still somewhat unstable (as it hasn't been properly optimized), so we recommend using the regular bard. Thank you.

By dev version, are you referring to a separate repository? 'cuz I don't see any dev branch in this repository.

iafuad

Before updating to PyPI, we conveniently refer to the main branch of the GitHub version as the 'dev' version. Please download and install from the GitHub repository. Once debugging is complete, we upload the official version to PyPI. We are preparing version 0.1.39.

$ pip install git+https://github.com/dsdanielpark/Bard-API.git

ahmadkeren

I will check 0.1.30 and 0.1.38

iafuad

Before updating to PyPI, we conveniently refer to the main branch of the GitHub version as the 'dev' version. Please download and install from the GitHub repository. Once debugging is complete, we upload the official version to PyPI. We are preparing version 0.1.39.

$ pip install git+https://github.com/dsdanielpark/Bard-API.git

The original issue is on the GitHub version though. I don't know about the PyPI version but the async class in GitHub version is completely unusable.

iafuad

I agree with your opinion.

The current PyPI version ( 0.1.38 ) is faulty. the older 0.1.30 is still the only one that works. I just checked this morning.

This issue has been resolved in bardapi version 0.1.39. Thank you for reporting the issue.

Bard API - version 0.1.39

$ pip install bardapi==0.1.39
$ pip install -q -U bardapi

https://github.com/dsdanielpark/Bard-API/blob/main/documents/README_DEV.md#using-bard-asynchronously

from httpx import AsyncClient
from bardapi import BardAsync
import os

# Uncomment and set your API key as needed
# os.environ['_BARD_API_KEY'] = 'xxxxxxx'
token = 'xxxxxxx'  # Replace with your actual token

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/",
}
timeout = 30  # Example timeout
proxies = {}  # Replace with your proxies if needed

client = AsyncClient(
    http2=True,
    headers=SESSION_HEADERS,
    cookies={"__Secure-1PSID": token},
    timeout=timeout,
    proxies=proxies,
)

bard_async = BardAsync(token=token, client=client)

# Asynchronous function to get the answer
async def get_bard_answer(question):
    await bard_async.async_setup()  # Ensure async setup is done
    return await bard_async.get_answer(question)

response = await get_bard_answer("나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘")
print(response['content'])

it works, thank you :)

raymerjacque

Thank you for your support. It has been a great help.

Also, you are welcome to contribute at any time by addressing new issues or refactoring packages.

We always look forward to your participation in the community. Thank you.

raymerjacque

Thank you for your support. It has been a great help.

Also, you are welcome to contribute at any time by addressing new issues or refactoring packages.

We always look forward to your participation in the community. Thank you.

thank you sir