Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,38 @@
|
|
| 1 |
#src/app.py
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from utils.session_state import initialize_session_state
|
| 4 |
-
from utils.database import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from components.chat import display_chat_interface
|
| 6 |
-
from utils.database import display_vector_store_info, handle_document_upload
|
| 7 |
from components.knowledge_base import display_knowledge_base
|
| 8 |
-
from components.upload import handle_document_upload
|
| 9 |
from config.settings import APP_SETTINGS
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
def main():
|
|
|
|
|
|
|
|
|
|
| 17 |
st.title("🤖 SYNAPTYX - RFP Analysis Agent")
|
| 18 |
st.markdown("Upload RFP documents, analyze requirements, and get intelligent answers powered by AI.")
|
| 19 |
|
|
@@ -30,8 +49,8 @@ def main():
|
|
| 30 |
if uploaded_files:
|
| 31 |
# Only process if files haven't been processed yet
|
| 32 |
if 'processed_files' not in st.session_state or uploaded_files != st.session_state.processed_files:
|
| 33 |
-
# Make sure we're using the correct function from database.py
|
| 34 |
handle_document_upload(uploaded_files)
|
|
|
|
| 35 |
st.session_state.processed_files = uploaded_files
|
| 36 |
|
| 37 |
# Knowledge Base Section
|
|
|
|
| 1 |
#src/app.py
|
| 2 |
+
|
| 3 |
import streamlit as st
|
| 4 |
from utils.session_state import initialize_session_state
|
| 5 |
+
from utils.database import (
|
| 6 |
+
get_documents,
|
| 7 |
+
insert_document,
|
| 8 |
+
display_vector_store_info,
|
| 9 |
+
handle_document_upload,
|
| 10 |
+
create_connection,
|
| 11 |
+
create_tables
|
| 12 |
+
)
|
| 13 |
from components.chat import display_chat_interface
|
|
|
|
| 14 |
from components.knowledge_base import display_knowledge_base
|
|
|
|
| 15 |
from config.settings import APP_SETTINGS
|
| 16 |
|
| 17 |
+
|
| 18 |
+
def initialize_database():
|
| 19 |
+
"""Initialize database connection and tables."""
|
| 20 |
+
if 'db_conn' not in st.session_state:
|
| 21 |
+
# Initialize database connection
|
| 22 |
+
conn = create_connection('rfp_analysis.db')
|
| 23 |
+
if conn is not None:
|
| 24 |
+
# Create tables
|
| 25 |
+
create_tables(conn)
|
| 26 |
+
# Store connection in session state
|
| 27 |
+
st.session_state.db_conn = conn
|
| 28 |
+
else:
|
| 29 |
+
st.error("Error! Cannot create the database connection.")
|
| 30 |
+
|
| 31 |
|
| 32 |
def main():
|
| 33 |
+
# Initialize database connection
|
| 34 |
+
initialize_database()
|
| 35 |
+
|
| 36 |
st.title("🤖 SYNAPTYX - RFP Analysis Agent")
|
| 37 |
st.markdown("Upload RFP documents, analyze requirements, and get intelligent answers powered by AI.")
|
| 38 |
|
|
|
|
| 49 |
if uploaded_files:
|
| 50 |
# Only process if files haven't been processed yet
|
| 51 |
if 'processed_files' not in st.session_state or uploaded_files != st.session_state.processed_files:
|
|
|
|
| 52 |
handle_document_upload(uploaded_files)
|
| 53 |
+
# Store the processed files to avoid reprocessing
|
| 54 |
st.session_state.processed_files = uploaded_files
|
| 55 |
|
| 56 |
# Knowledge Base Section
|