Spaces:
Runtime error
Runtime error
Add diagnostic functionality to debug GraphRAG mode
Browse files
app.py
CHANGED
|
@@ -265,6 +265,18 @@ def api_query(query: str, mode: str = "local", book_id: str = None):
|
|
| 265 |
finally:
|
| 266 |
loop.close()
|
| 267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
# Gradio app
|
| 269 |
with gr.Blocks(
|
| 270 |
title="Borges Graph - GraphRAG Explorer",
|
|
@@ -325,6 +337,10 @@ with gr.Blocks(
|
|
| 325 |
with gr.Accordion("🔧 Réponse JSON (pour développeurs)", open=False):
|
| 326 |
json_output = gr.Code(language="json", label="JSON Response")
|
| 327 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
# Event handlers
|
| 329 |
search_btn.click(
|
| 330 |
fn=query_interface,
|
|
@@ -338,6 +354,11 @@ with gr.Blocks(
|
|
| 338 |
outputs=[answer_output, json_output, summary_output]
|
| 339 |
)
|
| 340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
# Launch the app
|
| 342 |
if __name__ == "__main__":
|
| 343 |
app.launch(
|
|
|
|
| 265 |
finally:
|
| 266 |
loop.close()
|
| 267 |
|
| 268 |
+
# Diagnostic function
|
| 269 |
+
def diagnostic_info():
|
| 270 |
+
"""Return diagnostic information about the system"""
|
| 271 |
+
return {
|
| 272 |
+
"nano_graphrag_available": NANO_GRAPHRAG_AVAILABLE,
|
| 273 |
+
"available_books": available_books,
|
| 274 |
+
"current_book": borges_rag.current_book,
|
| 275 |
+
"working_directory": os.getcwd(),
|
| 276 |
+
"directory_contents": [f for f in os.listdir('.') if os.path.isdir(f)],
|
| 277 |
+
"book_status": book_status
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
# Gradio app
|
| 281 |
with gr.Blocks(
|
| 282 |
title="Borges Graph - GraphRAG Explorer",
|
|
|
|
| 337 |
with gr.Accordion("🔧 Réponse JSON (pour développeurs)", open=False):
|
| 338 |
json_output = gr.Code(language="json", label="JSON Response")
|
| 339 |
|
| 340 |
+
with gr.Accordion("🔍 Diagnostic système", open=False):
|
| 341 |
+
diag_btn = gr.Button("Obtenir diagnostic")
|
| 342 |
+
diag_output = gr.Code(language="json", label="Diagnostic Info")
|
| 343 |
+
|
| 344 |
# Event handlers
|
| 345 |
search_btn.click(
|
| 346 |
fn=query_interface,
|
|
|
|
| 354 |
outputs=[answer_output, json_output, summary_output]
|
| 355 |
)
|
| 356 |
|
| 357 |
+
diag_btn.click(
|
| 358 |
+
fn=lambda: json.dumps(diagnostic_info(), indent=2, ensure_ascii=False),
|
| 359 |
+
outputs=[diag_output]
|
| 360 |
+
)
|
| 361 |
+
|
| 362 |
# Launch the app
|
| 363 |
if __name__ == "__main__":
|
| 364 |
app.launch(
|