Samuel Oberhofer commited on
Commit ·
aa4b010
1
Parent(s): 8985b64
fix: Move setup logic into cached Streamlit function
Browse files- app.py +17 -0
- startup.sh +0 -6
app.py
CHANGED
|
@@ -6,6 +6,20 @@ import streamlit as st
|
|
| 6 |
import time
|
| 7 |
from guards import input as input_guard, output as output_guard
|
| 8 |
from rag import retriever
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# ============================================
|
| 11 |
# BACKEND INTEGRATION
|
|
@@ -49,6 +63,9 @@ def query_rag_pipeline(user_query: str) -> dict:
|
|
| 49 |
# ============================================
|
| 50 |
|
| 51 |
def main():
|
|
|
|
|
|
|
|
|
|
| 52 |
st.set_page_config(
|
| 53 |
page_title="Knowledge Retrieval System",
|
| 54 |
page_icon="🤖",
|
|
|
|
| 6 |
import time
|
| 7 |
from guards import input as input_guard, output as output_guard
|
| 8 |
from rag import retriever
|
| 9 |
+
from database.setup_db import setup_database
|
| 10 |
+
from rag.build_vector_store import build_vector_store
|
| 11 |
+
|
| 12 |
+
# ============================================
|
| 13 |
+
# APPLICATION SETUP
|
| 14 |
+
# ============================================
|
| 15 |
+
|
| 16 |
+
@st.cache_resource
|
| 17 |
+
def setup_application():
|
| 18 |
+
"""
|
| 19 |
+
Sets up the database and vector store on application startup.
|
| 20 |
+
"""
|
| 21 |
+
setup_database()
|
| 22 |
+
build_vector_store()
|
| 23 |
|
| 24 |
# ============================================
|
| 25 |
# BACKEND INTEGRATION
|
|
|
|
| 63 |
# ============================================
|
| 64 |
|
| 65 |
def main():
|
| 66 |
+
# Run the setup function
|
| 67 |
+
setup_application()
|
| 68 |
+
|
| 69 |
st.set_page_config(
|
| 70 |
page_title="Knowledge Retrieval System",
|
| 71 |
page_icon="🤖",
|
startup.sh
CHANGED
|
@@ -1,10 +1,4 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
| 3 |
-
# Set up the database
|
| 4 |
-
python3 database/setup_db.py
|
| 5 |
-
|
| 6 |
-
# Build the vector store
|
| 7 |
-
python3 rag/build_vector_store.py
|
| 8 |
-
|
| 9 |
# Run the Streamlit app
|
| 10 |
streamlit run app.py
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
# Run the Streamlit app
|
| 4 |
streamlit run app.py
|