vraman54 commited on
Commit
e3a1dab
1 Parent(s): 6ea185e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -20,6 +20,10 @@ config = {
20
  }
21
  }
22
 
 
 
 
 
23
 
24
  st.title("💬 Chatbot")
25
  if "messages" not in st.session_state:
@@ -30,13 +34,17 @@ if "messages" not in st.session_state:
30
  Hi! I'm a chatbot. I can answer your questions based on IPL Wiki Page""",
31
  }
32
  ]
33
- os.environ["HUGGINGFACE_ACCESS_TOKEN"] = st.secrets["HF_TOKEN"]
34
 
35
  for message in st.session_state.messages:
36
  with st.chat_message(message["role"]):
37
  st.markdown(message["content"])
38
 
39
  if prompt := st.chat_input("Ask me anything!"):
 
 
 
 
 
40
  app = App.from_config(config = config)
41
  app.add("https://en.wikipedia.org/wiki/Indian_Premier_League")
42
 
 
20
  }
21
  }
22
 
23
+ with st.sidebar:
24
+ huggingface_access_token = st.text_input("Hugging face Token", key="chatbot_api_key", type="password")
25
+ "[Get Hugging Face Access Token](https://huggingface.co/settings/tokens)"
26
+ "[View the source code](https://github.com/embedchain/examples/mistral-streamlit)"
27
 
28
  st.title("💬 Chatbot")
29
  if "messages" not in st.session_state:
 
34
  Hi! I'm a chatbot. I can answer your questions based on IPL Wiki Page""",
35
  }
36
  ]
 
37
 
38
  for message in st.session_state.messages:
39
  with st.chat_message(message["role"]):
40
  st.markdown(message["content"])
41
 
42
  if prompt := st.chat_input("Ask me anything!"):
43
+ if not st.session_state.chatbot_api_key:
44
+ st.error("Please enter your Hugging Face Access Token")
45
+ st.stop()
46
+
47
+ os.environ["HUGGINGFACE_ACCESS_TOKEN"] = st.session_state.chatbot_api_key
48
  app = App.from_config(config = config)
49
  app.add("https://en.wikipedia.org/wiki/Indian_Premier_League")
50