File size: 1,102 Bytes
72bf066
 
 
 
 
1a5468b
72bf066
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d45043b
 
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
# app.py
import streamlit as st
import requests

# Define the FastAPI endpoint URL
FASTAPI_URL = "http://localhost:8001/api/v1/rag/upload"

st.title("Document Summarizer")

# File uploader
uploaded_file = st.file_uploader("Choose a PDF file", type="pdf")

# Text input for the question
question = st.text_input("Enter your question")

# Button to submit the file and question
if st.button("Get Summary"):
    if uploaded_file and question:
        # Use a form to submit the file and question
        with st.spinner('Processing...'):
            files = {"doc": uploaded_file.getvalue()}
            response = requests.post(FASTAPI_URL, files={"doc": uploaded_file}, data={"question": question})
            
            if response.status_code == 200:
                result = response.json()
                st.success("Response received successfully!")
                st.write(result["data"])
            else:
                st.error(f"Error: {response.status_code}")
                st.write(response.json())
    else:
        st.warning("Please upload a file and enter a question.")