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.
uvicorn main:app --reload --port 8000
INFO: Will watch for changes in these directories: ['/opt/google-bard-api']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [1293] using StatReload
INFO: Started server process [1301]
INFO: Waiting for application startup.
INFO: Application startup complete.
for example when executing a request:
curl -X POST "http://localhost:8000/ask" -H "accept: application/json" -H "Content-Type: application/json" -d '{"session_id":"ZQjhVqyLaEkcPex9Wkq-HuIVd1DWsk24PVQVKHxrXrE3EkeKssgO4E4sdrzgzFXKjf05jA.","message":"What is HS code for asus vivo notebook?"}'
INFO: 127.0.0.1:59330 - "POST /ask HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/applications.py", line 292, in call
await super().call(scope, receive, send)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/applications.py", line 122, in call
await self.middleware_stack(scope, receive, send)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in call
raise exc
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in call
await self.app(scope, receive, _send)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in call
raise exc
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in call
await self.app(scope, receive, sender)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in call
raise e
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in call
await self.app(scope, receive, send)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/routing.py", line 718, in call
await route.handle(scope, receive, send)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
await self.app(scope, receive, send)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
response = await func(request)
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/routing.py", line 273, in app
raw_response = await run_endpoint_function(
File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
return await dependant.call(**values)
File "/opt/google-bard-api/main.py", line 25, in ask
chatbot = Chatbot(message.session_id)
File "/opt/google-bard-api/Bard.py", line 99, in init
self.SNlM0e = self.__get_snlm0e()
File "/opt/google-bard-api/Bard.py", line 105, in __get_snlm0e
raise Exception("Could not get Google Bard")
Exception: Could not get Google Bard
After installation
uvicorn main:app --reload --port 8000 INFO: Will watch for changes in these directories: ['/opt/google-bard-api'] INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [1293] using StatReload INFO: Started server process [1301] INFO: Waiting for application startup. INFO: Application startup complete.
for example when executing a request: curl -X POST "http://localhost:8000/ask" -H "accept: application/json" -H "Content-Type: application/json" -d '{"session_id":"ZQjhVqyLaEkcPex9Wkq-HuIVd1DWsk24PVQVKHxrXrE3EkeKssgO4E4sdrzgzFXKjf05jA.","message":"What is HS code for asus vivo notebook?"}'
INFO: 127.0.0.1:59330 - "POST /ask HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "/opt/google-bard-api/venv/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi result = await app( # type: ignore[func-returns-value] File "/opt/google-bard-api/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call return await self.app(scope, receive, send) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/applications.py", line 292, in call await super().call(scope, receive, send) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/applications.py", line 122, in call await self.middleware_stack(scope, receive, send) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in call raise exc File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in call await self.app(scope, receive, _send) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in call raise exc File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in call await self.app(scope, receive, sender) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in call raise e File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in call await self.app(scope, receive, send) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/routing.py", line 718, in call await route.handle(scope, receive, send) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle await self.app(scope, receive, send) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/starlette/routing.py", line 66, in app response = await func(request) File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/routing.py", line 273, in app raw_response = await run_endpoint_function( File "/opt/google-bard-api/venv/lib/python3.9/site-packages/fastapi/routing.py", line 190, in run_endpoint_function return await dependant.call(**values) File "/opt/google-bard-api/main.py", line 25, in ask chatbot = Chatbot(message.session_id) File "/opt/google-bard-api/Bard.py", line 99, in init self.SNlM0e = self.__get_snlm0e() File "/opt/google-bard-api/Bard.py", line 105, in __get_snlm0e raise Exception("Could not get Google Bard") Exception: Could not get Google Bard
Please tell me what could be the reason?