Spaces:
Sleeping
Sleeping
File size: 884 Bytes
8705b8d 75230cb 647b7f2 4265c8b 8705b8d 75230cb 8705b8d 75230cb 8705b8d 75230cb 8705b8d ca44c23 75230cb 8705b8d 75230cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import streamlit as st
from data_preprocessing import preprocess_csv
from question_answering import answer_query
# Streamlit app
st.title("Question Answering App")
# Textbox for user query
user_query = st.text_input("Enter your question:")
# File uploader for context (Hugging Face specific)
uploaded_file = st.file_uploader("Upload a CSV file from Hugging Face Hub:", type="text")
if uploaded_file is not None:
# Extract file URL
file_url = uploaded_file.url
# Preprocess the CSV data
context = preprocess_csv(file_url)
else:
# Use default context (optional)
context = "This is a sample context for demonstration purposes. You can upload your own text file or CSV file for context."
# Answer the query if a question is provided
if user_query:
answer = answer_query(user_query, context)
st.write(f"Answer: {answer}")
else:
st.write("Please enter a question.")
|