Hello,
I have a simple code that works perfectly on my local machine but generates an error when deployed on Streamlit. I am using the bardapi from GitHub - dsdanielpark/Bard-API: The unofficial python package that returns response of Google Bard through cookie value. and using the latest version. in requirements.txt I am using bardapi==0.1.29
import streamlit as st
from dotenv.main import load_dotenv
import os
load_dotenv()
st.title("BardAPI for Python")
_BARD_API_KEY=os.environ['_BARD_API_KEY']
#import os
from bardapi import Bard
with st.container () :
with st.spinner ( 'Wait till Bard gets the answers...' ) :
input_text = "What is the largest state in the USA?"
try :
bard = Bard ( token = _BARD_API_KEY, timeout = 20 )
response = (bard.get_answer ( input_text ) [ 'content' ])
st.write ( response )
except :
st.error ( 'Please check if you have set the Cookie ' )
on the local machine I get:
BardAPI for Python
The largest state in the USA is Alaska. It has a total area of 586,412 square miles, which is more than two and a half times the size of Texas, the second largest state. Alaska is also the least densely populated state in the USA, with a population of only about 733,000 people.
Here is a list of the 10 largest states in the USA, ranked by total area:
- Alaska (586,412 square miles)
- Texas (268,596 square miles)
- California (163,695 square miles)
- Montana (147,046 square miles)
- New Mexico (121,590 square miles)
- Arizona (113,990 square miles)
- Nevada (110,572 square miles)
- Colorado (104,094 square miles)
- Oregon (98,379 square miles)
- Wyoming (97,813 square miles)
I hope this helps! Let me know if you have any other questions.
on Streamlit Hub I get:
BardAPI for Python
Response Error: b’)]}‘\n\n38\n[[“wrb.fr”,null,null,null,null,[9]]]\n56\n[[“di”,163],[“af.httprm”,163,“7269046257447756350”,0]]\n25\n[[“e”,4,null,null,131]]\n’. Unable to get response. Please double-check the cookie values and verify your network environment or google account.
I am using the same cookie; nothing changed.
Any help is appreciated.
Thank you
GR