sabssag commited on
Commit
c8b2231
·
verified ·
1 Parent(s): 3b75727

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -14
app.py CHANGED
@@ -10,16 +10,8 @@ qa_pipeline = pipeline("question-answering", model=model_path, tokenizer=model_p
10
  # Set the title for the Streamlit app
11
  st.title("Movie Trivia Question Answering")
12
 
13
- # Load the context from a predefined file
14
- context_file_path = 'contexts.txt' # Replace with the actual path to your context file
15
- with open(context_file_path, 'r') as file:
16
- context = file.read()
17
-
18
- # Display the context to the user
19
- st.subheader("Context (movie-related text)")
20
- st.write(context)
21
-
22
- # Text input for the user to enter the question
23
  question = st.text_area("Enter your question:")
24
 
25
  def generate_answer(question, context):
@@ -28,15 +20,15 @@ def generate_answer(question, context):
28
  return result['answer']
29
 
30
  if st.button("Get Answer"):
31
- if question:
32
  generated_answer = generate_answer(question, context)
33
  # Display the generated answer
34
  st.subheader("Answer")
35
  st.write(generated_answer)
36
  else:
37
- st.warning("Please enter a question.")
38
 
39
  # Optionally, add instructions or information about the app
40
  st.write("""
41
- Enter a question related to the provided movie-related context above. The model will provide the answer based on the context.
42
- """)
 
10
  # Set the title for the Streamlit app
11
  st.title("Movie Trivia Question Answering")
12
 
13
+ # Text inputs for the user
14
+ context = st.text_area("Enter the context (movie-related text):")
 
 
 
 
 
 
 
 
15
  question = st.text_area("Enter your question:")
16
 
17
  def generate_answer(question, context):
 
20
  return result['answer']
21
 
22
  if st.button("Get Answer"):
23
+ if context and question:
24
  generated_answer = generate_answer(question, context)
25
  # Display the generated answer
26
  st.subheader("Answer")
27
  st.write(generated_answer)
28
  else:
29
+ st.warning("Please enter both context and question.")
30
 
31
  # Optionally, add instructions or information about the app
32
  st.write("""
33
+ Enter a movie-related context and a question related to the context above. The model will provide the answer based on the context provided.
34
+ """)