Aidahaouas commited on
Commit
d3f072a
·
verified ·
1 Parent(s): fe797b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -6,10 +6,29 @@ from pinecone_utilsB import *
6
  from graph_agentA import agent as agent_A
7
  from graph_agentB import agent as agent_B
8
  from functions import *
 
 
9
 
10
-
 
 
 
 
 
 
 
 
 
 
 
11
  # Point d'entrée de l'application
12
  def main():
 
 
 
 
 
 
13
  # Initialiser l'historique de chat s'il n'existe pas
14
  if "chat_history" not in st.session_state:
15
  st.session_state.chat_history = []
@@ -29,7 +48,4 @@ def main():
29
  process_query_B(query)
30
  else:
31
  process_query_A(query)
32
- st.rerun()
33
-
34
- if __name__ == "__main__":
35
- main()
 
6
  from graph_agentA import agent as agent_A
7
  from graph_agentB import agent as agent_B
8
  from functions import *
9
+ from config import *
10
+ from dotenv import load_dotenv
11
 
12
+ def load_existing_indexes():
13
+ """Se connecter aux index Pinecone existants."""
14
+ try:
15
+ # Connexion aux index
16
+ sparse_index = pc.Index(sparse_index_name)
17
+ dense_index = pc.Index(dense_index_name)
18
+ st.write(f"Connexion aux index '{sparse_index_name}' et '{dense_index_name}' réussie.")
19
+ return sparse_index, dense_index
20
+ except Exception as e:
21
+ st.error(f"Erreur lors de la connexion aux index Pinecone : {e}")
22
+ return None, None
23
+
24
  # Point d'entrée de l'application
25
  def main():
26
+ # Charger les index existants au démarrage
27
+ sparse_index, dense_index = load_existing_indexes()
28
+ if not sparse_index or not dense_index:
29
+ st.error("Impossible de se connecter aux index Pinecone. Vérifiez votre configuration.")
30
+ return
31
+
32
  # Initialiser l'historique de chat s'il n'existe pas
33
  if "chat_history" not in st.session_state:
34
  st.session_state.chat_history = []
 
48
  process_query_B(query)
49
  else:
50
  process_query_A(query)
51
+ st.rerun()