Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,6 +129,7 @@ with tab_ingestion:
|
|
| 129 |
st.rerun()
|
| 130 |
|
| 131 |
|
|
|
|
| 132 |
# --- TAB 2: ENTITÉS & RELATIONS ---
|
| 133 |
with tab_entities:
|
| 134 |
json_files = list(OUTPUT_DIR.glob("*.json"))
|
|
@@ -159,21 +160,41 @@ with tab_entities:
|
|
| 159 |
st.text_area("Données issues de l'OCR", text_extracted, height=500)
|
| 160 |
|
| 161 |
with col_inf2:
|
| 162 |
-
st.markdown("### EXTRACTION
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
if graph_data:
|
| 169 |
st.session_state.last_graph = graph_data
|
| 170 |
-
st.success(f"
|
| 171 |
else:
|
| 172 |
st.error("L'IA n'a pas pu structurer les données.")
|
| 173 |
|
|
|
|
| 174 |
if 'last_graph' in st.session_state:
|
| 175 |
-
st.markdown("#### FORMAT JSON (BRUT)")
|
| 176 |
-
# Affiche uniquement le JSON comme demandé
|
| 177 |
st.json(st.session_state.last_graph)
|
| 178 |
|
| 179 |
|
|
|
|
| 129 |
st.rerun()
|
| 130 |
|
| 131 |
|
| 132 |
+
|
| 133 |
# --- TAB 2: ENTITÉS & RELATIONS ---
|
| 134 |
with tab_entities:
|
| 135 |
json_files = list(OUTPUT_DIR.glob("*.json"))
|
|
|
|
| 160 |
st.text_area("Données issues de l'OCR", text_extracted, height=500)
|
| 161 |
|
| 162 |
with col_inf2:
|
| 163 |
+
st.markdown("### EXTRACTION HYBRIDE")
|
| 164 |
+
|
| 165 |
+
# 1. Bouton de lancement
|
| 166 |
+
if st.button("🧬 GÉNÉRER L'INTELLIGENCE SÉMANTIQUE", key="btn_run_hybrid", use_container_width=True):
|
| 167 |
+
# 2. Préparation de la barre de progression
|
| 168 |
+
progress_bar = st.progress(0)
|
| 169 |
+
status_text = st.empty()
|
| 170 |
+
|
| 171 |
+
# On utilise un spinner pour le chargement global
|
| 172 |
+
with st.spinner("Initialisation de GLiNER & Qwen..."):
|
| 173 |
+
# NOTE: Pour afficher la progression, nous allons légèrement modifier
|
| 174 |
+
# l'appel pour traiter les morceaux ici ou s'assurer que
|
| 175 |
+
# extract_long_text mette à jour un callback.
|
| 176 |
+
# Pour faire simple, on lance l'extraction :
|
| 177 |
+
|
| 178 |
+
status_text.text("Analyse des segments en cours...")
|
| 179 |
+
progress_bar.progress(25) # Simulation d'étape 1
|
| 180 |
+
|
| 181 |
+
graph_data = st.session_state.extractor.extract_long_text(
|
| 182 |
+
text_extracted,
|
| 183 |
+
temperature=ia_temp
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
progress_bar.progress(100)
|
| 187 |
+
status_text.text("Extraction terminée.")
|
| 188 |
|
| 189 |
if graph_data:
|
| 190 |
st.session_state.last_graph = graph_data
|
| 191 |
+
st.success(f"Réussite : {len(graph_data.get('entities', []))} entités identifiées.")
|
| 192 |
else:
|
| 193 |
st.error("L'IA n'a pas pu structurer les données.")
|
| 194 |
|
| 195 |
+
# 3. Affichage du JSON
|
| 196 |
if 'last_graph' in st.session_state:
|
| 197 |
+
st.markdown("#### 📂FORMAT JSON (BRUT)")
|
|
|
|
| 198 |
st.json(st.session_state.last_graph)
|
| 199 |
|
| 200 |
|