Imsachinsingh00 commited on
Commit
7dcca7a
Β·
1 Parent(s): 0aef548

Initial and final commit

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -1,10 +1,8 @@
1
  import streamlit as st
2
  from langchain.llms import HuggingFaceHub
3
  import os
4
- from langchain.llms import HuggingFaceHub
5
 
6
  st.set_page_config(page_title="Educational Chatbot")
7
-
8
  st.title("πŸŽ“ Educational Chatbot")
9
 
10
  user_input = st.text_input("Ask me anything:")
@@ -13,15 +11,17 @@ if "history" not in st.session_state:
13
  st.session_state.history = []
14
 
15
  if user_input:
16
- llm = HuggingFaceHub(
17
- repo_id="tiiuae/falcon-7b-instruct",
18
- huggingfacehub_api_token=os.environ.get("Educational_chatbot"),
19
- model_kwargs={"temperature": 0.5, "max_new_tokens": 100}
20
- )
21
-
22
- response = llm(user_input)
23
- st.session_state.history.append(("You", user_input))
24
- st.session_state.history.append(("Bot", response))
 
 
25
 
26
  for sender, msg in reversed(st.session_state.history):
27
  st.markdown(f"**{sender}:** {msg}")
 
1
  import streamlit as st
2
  from langchain.llms import HuggingFaceHub
3
  import os
 
4
 
5
  st.set_page_config(page_title="Educational Chatbot")
 
6
  st.title("πŸŽ“ Educational Chatbot")
7
 
8
  user_input = st.text_input("Ask me anything:")
 
11
  st.session_state.history = []
12
 
13
  if user_input:
14
+ try:
15
+ llm = HuggingFaceHub(
16
+ repo_id="tiiuae/falcon-7b-instruct",
17
+ huggingfacehub_api_token=os.environ.get("HUGGINGFACEHUB_API_TOKEN"),
18
+ model_kwargs={"temperature": 0.5, "max_new_tokens": 100}
19
+ )
20
+ response = llm(user_input)
21
+ st.session_state.history.append(("You", user_input))
22
+ st.session_state.history.append(("Bot", response))
23
+ except Exception as e:
24
+ st.error(f"⚠️ Error: {e}")
25
 
26
  for sender, msg in reversed(st.session_state.history):
27
  st.markdown(f"**{sender}:** {msg}")