Guillaumedbx commited on
Commit
8553e6c
·
1 Parent(s): 42716f2

fix version torch

Browse files
Files changed (2) hide show
  1. requirements.txt +3 -3
  2. src/streamlit_app.py +4 -33
requirements.txt CHANGED
@@ -6,11 +6,11 @@ langchain-community
6
  sentence-transformers
7
  chromadb
8
  transformers>=4.36.0
9
- torch>=2.1.0
10
  sentencepiece
11
  tqdm
12
  accelerate
13
 
14
 
15
-
16
-
 
6
  sentence-transformers
7
  chromadb
8
  transformers>=4.36.0
9
+ torch==2.0.1
10
  sentencepiece
11
  tqdm
12
  accelerate
13
 
14
 
15
+ pandas
16
+ langchain-core
src/streamlit_app.py CHANGED
@@ -68,30 +68,6 @@ similarity_threshold = st.sidebar.slider(
68
  step=5
69
  )
70
 
71
- def get_base_stats(source_key, source_dir):
72
- # Nombre de documents indexés dans la base vectorielle
73
- try:
74
- embeddings = get_local_embeddings()
75
- db_path = os.path.abspath("./db")
76
- db = Chroma(persist_directory=db_path, embedding_function=embeddings)
77
- # On compte les documents dont la métadonnée 'source' correspond
78
- docs = db.get(where={"source": source_key})
79
- nb_docs = len(docs.get("ids", []))
80
- except Exception:
81
- nb_docs = 0
82
- # Date de dernière indexation = fichier le plus récent du dossier source
83
- last_index_date = None
84
- try:
85
- dir_path = os.path.join("data", source_dir)
86
- if os.path.exists(dir_path):
87
- files = [os.path.join(dir_path, f) for f in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, f))]
88
- if files:
89
- last_mtime = max(os.path.getmtime(f) for f in files)
90
- last_index_date = datetime.datetime.fromtimestamp(last_mtime).strftime("%d/%m/%Y %H:%M")
91
- except Exception:
92
- pass
93
- return nb_docs, last_index_date
94
-
95
  # Choix multi-bases avec checkbox
96
  st.sidebar.markdown("**Bases de documents à interroger :**")
97
  base_options = [
@@ -103,15 +79,10 @@ selected_bases = [
103
  key for label, key, _ in base_options if st.sidebar.checkbox(label, value=True)
104
  ]
105
 
106
- # Affichage des stats pour chaque base
107
- st.sidebar.markdown(":mag: **Statistiques des bases**")
108
- for label, key, data_dir in base_options:
109
- nb_docs, last_index = get_base_stats(key, data_dir)
110
- st.sidebar.markdown(f"- **{label}** : {nb_docs} document(s) indexé(s)")
111
- if last_index:
112
- st.sidebar.markdown(f" <span style='color:gray;font-size:90%'>Dernière indexation : {last_index}</span>", unsafe_allow_html=True)
113
- else:
114
- st.sidebar.markdown(f" <span style='color:gray;font-size:90%'>Aucune indexation détectée</span>", unsafe_allow_html=True)
115
 
116
  # Affichage des modèles utilisés (en bas de la sidebar)
117
  st.sidebar.markdown("---")
 
68
  step=5
69
  )
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  # Choix multi-bases avec checkbox
72
  st.sidebar.markdown("**Bases de documents à interroger :**")
73
  base_options = [
 
79
  key for label, key, _ in base_options if st.sidebar.checkbox(label, value=True)
80
  ]
81
 
82
+ # Vérification qu'au moins une base est sélectionnée
83
+ if not selected_bases:
84
+ st.sidebar.warning("⚠️ Veuillez sélectionner au moins une base de documents pour continuer.")
85
+ st.stop()
 
 
 
 
 
86
 
87
  # Affichage des modèles utilisés (en bas de la sidebar)
88
  st.sidebar.markdown("---")