ra83205 / google-bard-api

This project provides a FastAPI wrapper for interacting with Google Bard, a conversational AI by Google. It allows users to send messages to Google Bard and receive responses through a simple API.
255 stars 60 forks source link

AttributeError: 'NoneType' object has no attribute 'group' #12

Closed dreamfast closed 1 year ago

dreamfast commented 1 year ago

This popped up today. Did Google finally kill off outside access? I think somehow the response from bard has changed.

I have tried a few new sessions from the cookie as per the readme, however facing the same result.

INFO:     51.161.161.54:42734 - "POST /ask HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 428, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
  File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 163, in run_endpoint_function
    return await dependant.call(**values)
  File "/app/main.py", line 25, in ask
    chatbot = Chatbot(message.session_id)
  File "/app/Bard.py", line 99, in __init__
    self.SNlM0e = self.__get_snlm0e()
  File "/app/Bard.py", line 106, in __get_snlm0e
    SNlM0e = re.search(r"SNlM0e\":\"(.*?)\"", resp.text).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
dreamfast commented 1 year ago

Sorry this was me getting the value from the header and not the cookie, still working as expected! Thanks

ducthong230497 commented 1 year ago

I'm currently facing this issue. Is there anything change in google bard api. I'm getting the session_id from cookie __Secure-1PSID