Spaces:
Sleeping
Sleeping
File size: 1,034 Bytes
1672ce6 8705b8d 75230cb 647b7f2 4265c8b 8705b8d 75230cb 332f69b 8705b8d 8c3c6aa 75230cb 8c3c6aa 1672ce6 8c3c6aa 1672ce6 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 31 32 33 34 35 |
import pandas as pd
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="CSV")
if uploaded_file is not None:
# Read the CSV data using pandas
df = pd.read_csv(uploaded_file)
# Preprocess the CSV data
context = preprocess_csv(df) # Assuming preprocess_csv can handle DataFrame input
# Display the uploaded CSV data as a table
st.dataframe(df)
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.")
|