Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
|
3 |
# FIRST: Set page config before ANY other Streamlit command
|
4 |
st.set_page_config(page_title="Indian Spiritual RAG")
|
@@ -54,25 +55,30 @@ if not st.session_state.initialized:
|
|
54 |
# Preload the model to avoid session state issues
|
55 |
if not st.session_state.initialized:
|
56 |
try:
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
62 |
except Exception as e:
|
63 |
st.error(f"Error initializing: {str(e)}")
|
64 |
|
65 |
# Function to process when enter is pressed or button is clicked
|
66 |
def process_input():
|
67 |
-
st.session_state.last_query = st.session_state.
|
68 |
-
st.session_state.
|
69 |
st.session_state.submit_clicked = True
|
70 |
|
71 |
# Query input with callback for Enter key
|
72 |
query = st.text_input(
|
73 |
"Ask your question:",
|
74 |
-
key="
|
75 |
-
on_change=process_input
|
76 |
)
|
77 |
|
78 |
# Display the current question if there is one
|
|
|
1 |
import streamlit as st
|
2 |
+
import time
|
3 |
|
4 |
# FIRST: Set page config before ANY other Streamlit command
|
5 |
st.set_page_config(page_title="Indian Spiritual RAG")
|
|
|
55 |
# Preload the model to avoid session state issues
|
56 |
if not st.session_state.initialized:
|
57 |
try:
|
58 |
+
init_message = st.empty()
|
59 |
+
init_message.info("Hang in there! We are setting the system up for you. 😊")
|
60 |
+
|
61 |
+
# Force model loading at startup to avoid session state issues
|
62 |
+
load_model()
|
63 |
+
|
64 |
+
# Keep the message for 2 seconds before replacing it
|
65 |
+
time.sleep(2)
|
66 |
+
init_message.success("System initialized successfully!")
|
67 |
+
st.session_state.initialized = True
|
68 |
except Exception as e:
|
69 |
st.error(f"Error initializing: {str(e)}")
|
70 |
|
71 |
# Function to process when enter is pressed or button is clicked
|
72 |
def process_input():
|
73 |
+
st.session_state.last_query = st.session_state.query_input
|
74 |
+
st.session_state.query_input = ""
|
75 |
st.session_state.submit_clicked = True
|
76 |
|
77 |
# Query input with callback for Enter key
|
78 |
query = st.text_input(
|
79 |
"Ask your question:",
|
80 |
+
key="query_input",
|
81 |
+
on_change=process_input
|
82 |
)
|
83 |
|
84 |
# Display the current question if there is one
|