Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| import os | |
| from utils import process_uploaded_file | |
| from groq_api import ask_groq | |
| st.set_page_config(page_title="Multidoc Chat", layout="wide") | |
| st.title("๐ Multidoc Chat - Ask Anything About Your Files") | |
| uploaded_file = st.file_uploader("Upload PDF or Excel", type=["pdf", "xlsx"]) | |
| if uploaded_file: | |
| with st.spinner("Processing file..."): | |
| extracted_text = process_uploaded_file(uploaded_file) | |
| if "history" not in st.session_state: | |
| st.session_state.history = [] | |
| st.text_area("Extracted Text Preview", extracted_text[:1000], height=150, disabled=True) | |
| user_query = st.text_input("Ask something about the document:") | |
| if st.button("Get Answer") and user_query: | |
| response = ask_groq(user_query, extracted_text) | |
| st.session_state.history.append((user_query, response)) | |
| if st.session_state.history: | |
| st.write("### Chat History:") | |
| for q, a in st.session_state.history: | |
| st.write(f"**Q:** {q}") | |
| st.write(f"**A:** {a}") | |