Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,31 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
# Load the pipeline
|
8 |
-
qa_pipeline = pipeline("question-answering", model=model_path, tokenizer=model_path)
|
9 |
|
10 |
# Set the title for the Streamlit app
|
11 |
-
st.title("Movie Trivia
|
12 |
|
13 |
-
# Text
|
14 |
-
|
15 |
-
question = st.text_area("Enter your question:")
|
16 |
|
17 |
-
def
|
18 |
-
#
|
19 |
-
|
20 |
-
return
|
21 |
|
22 |
if st.button("Get Answer"):
|
23 |
-
if
|
24 |
-
|
25 |
-
# Display the
|
26 |
-
st.subheader("
|
27 |
-
st.write(
|
28 |
else:
|
29 |
-
st.warning("Please enter
|
30 |
|
31 |
# Optionally, add instructions or information about the app
|
32 |
st.write("""
|
33 |
-
Enter a movie-related
|
34 |
""")
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the conversational pipeline
|
5 |
+
model_name = "QAModel"
|
6 |
+
chatbot_pipeline = pipeline("conversational", model=model_name, tokenizer=model_name)
|
|
|
|
|
7 |
|
8 |
# Set the title for the Streamlit app
|
9 |
+
st.title("Movie Trivia Chatbot")
|
10 |
|
11 |
+
# Text input for the user
|
12 |
+
user_input = st.text_area("Ask a movie trivia question:")
|
|
|
13 |
|
14 |
+
def get_response(user_input):
|
15 |
+
# Generate response
|
16 |
+
conversation = chatbot_pipeline(user_input)
|
17 |
+
return conversation[0]['generated_text']
|
18 |
|
19 |
if st.button("Get Answer"):
|
20 |
+
if user_input:
|
21 |
+
response = get_response(user_input)
|
22 |
+
# Display the response
|
23 |
+
st.subheader("Answer")
|
24 |
+
st.write(response)
|
25 |
else:
|
26 |
+
st.warning("Please enter a question.")
|
27 |
|
28 |
# Optionally, add instructions or information about the app
|
29 |
st.write("""
|
30 |
+
Enter a movie-related question above. The chatbot will provide an answer based on its training.
|
31 |
""")
|