Spaces:
Sleeping
Sleeping
Commit
Β·
7dcca7a
1
Parent(s):
0aef548
Initial and final commit
Browse files
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 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
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}")
|