Spaces:
Sleeping
Sleeping
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.") | |