Spaces:
Sleeping
Sleeping
Change session state initialisation
Browse files
app.py
CHANGED
@@ -21,19 +21,19 @@ def init_app():
|
|
21 |
if "user" in query_params:
|
22 |
st.session_state["id_user"] = query_params["user"]
|
23 |
|
24 |
-
|
25 |
-
if
|
26 |
-
# Define Vectore store strategy
|
27 |
-
pinecone_connector = PineconeConnector()
|
28 |
-
vs_manager = VectoreStoreManager(pinecone_connector)
|
29 |
-
|
30 |
st.session_state["retrived_documents"] = []
|
|
|
31 |
st.session_state["messages"] = []
|
|
|
32 |
st.session_state["remove_undefined_value"] = True
|
|
|
|
|
|
|
|
|
33 |
st.session_state["assistant"] = Rag(vectore_store=vs_manager)
|
34 |
-
|
35 |
-
st.session_state["prompt_system"] = config['prompt_system']
|
36 |
-
|
37 |
if 'parts' in config['variables']:
|
38 |
# Flatten structure by adding part name to each field
|
39 |
st.session_state["data_dict"] = [
|
@@ -44,6 +44,9 @@ def init_app():
|
|
44 |
else:
|
45 |
# Initialize session state with single list of variables
|
46 |
st.session_state["data_dict"] = [{**field} for field in config["variables"]]
|
|
|
|
|
|
|
47 |
|
48 |
|
49 |
def main():
|
|
|
21 |
if "user" in query_params:
|
22 |
st.session_state["id_user"] = query_params["user"]
|
23 |
|
24 |
+
# Initialize session state keys if they are not already defined
|
25 |
+
if "retrived_documents" not in st.session_state:
|
|
|
|
|
|
|
|
|
26 |
st.session_state["retrived_documents"] = []
|
27 |
+
if "messages" not in st.session_state:
|
28 |
st.session_state["messages"] = []
|
29 |
+
if "remove_undefined_value" not in st.session_state:
|
30 |
st.session_state["remove_undefined_value"] = True
|
31 |
+
if "assistant" not in st.session_state:
|
32 |
+
# Define Vectore store strategy
|
33 |
+
pinecone_connector = PineconeConnector()
|
34 |
+
vs_manager = VectoreStoreManager(pinecone_connector)
|
35 |
st.session_state["assistant"] = Rag(vectore_store=vs_manager)
|
36 |
+
if "data_dict" not in st.session_state:
|
|
|
|
|
37 |
if 'parts' in config['variables']:
|
38 |
# Flatten structure by adding part name to each field
|
39 |
st.session_state["data_dict"] = [
|
|
|
44 |
else:
|
45 |
# Initialize session state with single list of variables
|
46 |
st.session_state["data_dict"] = [{**field} for field in config["variables"]]
|
47 |
+
|
48 |
+
if "prompt_system" not in st.session_state:
|
49 |
+
st.session_state["prompt_system"] = config['prompt_system']
|
50 |
|
51 |
|
52 |
def main():
|