Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ os.makedirs(DATA_DIR, exist_ok=True)
|
|
| 32 |
os.makedirs(PERSIST_DIR, exist_ok=True)
|
| 33 |
|
| 34 |
# Fixed PDF file path
|
| 35 |
-
FIXED_PDF_PATH = os.path.join(DATA_DIR, "
|
| 36 |
|
| 37 |
# Function to display the PDF
|
| 38 |
def displayPDF(file):
|
|
@@ -42,7 +42,7 @@ def displayPDF(file):
|
|
| 42 |
st.markdown(pdf_display, unsafe_allow_html=True)
|
| 43 |
|
| 44 |
# Ingest data once on startup
|
| 45 |
-
@st.
|
| 46 |
def load_data():
|
| 47 |
documents = SimpleDirectoryReader(DATA_DIR).load_data()
|
| 48 |
storage_context = StorageContext.from_defaults()
|
|
@@ -75,6 +75,10 @@ def handle_query(query, index):
|
|
| 75 |
else:
|
| 76 |
return "Lo siento, no puedo buscar esa respuesta"
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# Streamlit app initialization
|
| 79 |
st.title("(PDF) Información e Inferencia🗞️")
|
| 80 |
st.markdown("Generación Aumentada con Recuperación")
|
|
|
|
| 32 |
os.makedirs(PERSIST_DIR, exist_ok=True)
|
| 33 |
|
| 34 |
# Fixed PDF file path
|
| 35 |
+
FIXED_PDF_PATH = os.path.join(DATA_DIR, "data_saved_pdf.pdf")
|
| 36 |
|
| 37 |
# Function to display the PDF
|
| 38 |
def displayPDF(file):
|
|
|
|
| 42 |
st.markdown(pdf_display, unsafe_allow_html=True)
|
| 43 |
|
| 44 |
# Ingest data once on startup
|
| 45 |
+
@st.cache_data(allow_output_mutation=True)
|
| 46 |
def load_data():
|
| 47 |
documents = SimpleDirectoryReader(DATA_DIR).load_data()
|
| 48 |
storage_context = StorageContext.from_defaults()
|
|
|
|
| 75 |
else:
|
| 76 |
return "Lo siento, no puedo buscar esa respuesta"
|
| 77 |
|
| 78 |
+
# Initialize session state
|
| 79 |
+
if 'messages' not in st.session_state:
|
| 80 |
+
st.session_state.messages = [{'role': 'assistant', "content": '¡Hola! Sube un PDF y pregúntame lo que quieras sobre su contenido.'}]
|
| 81 |
+
|
| 82 |
# Streamlit app initialization
|
| 83 |
st.title("(PDF) Información e Inferencia🗞️")
|
| 84 |
st.markdown("Generación Aumentada con Recuperación")
|