+
+
+
+ {{ result.title }}
+
+
+ {% if result.text and result.text != result.title %}
+
+ {% if result.text|length > 400 %}
+ {{ result.text[:397] }}...
+ {% else %}
+ {{ result.text }}
+ {% endif %}
+
+ {% endif %}
+
+ {% if result.concepts %}
+
+ Concepts :
+ {% for concept in result.concepts[:8] %}
+ {{ concept }}
+ {% endfor %}
+ {% if result.concepts|length > 8 %}
+ +{{ result.concepts|length - 8 }} autres
+ {% endif %}
+
+ {% endif %}
+
+
+ {% if result.chunks_count > 0 %}
+
+ 📄 {{ result.chunks_count }} passage{% if result.chunks_count > 1 %}s{% endif %} détaillé{% if result.chunks_count > 1 %}s{% endif %}
+
+ {% endif %}
+ {% if result.section_path %}
+ │ Section : {{ result.section_path[:70] }}{% if result.section_path|length > 70 %}...{% endif %}
+ {% endif %}
+
+
+ {% endfor %}
+
{% else %}
{% for result in results_data.results %}
diff --git a/generations/library_rag/test_hierarchical_fix.py b/generations/library_rag/test_hierarchical_fix.py
new file mode 100644
index 0000000..03b87c7
--- /dev/null
+++ b/generations/library_rag/test_hierarchical_fix.py
@@ -0,0 +1,94 @@
+"""Test hierarchical search mode after fix."""
+
+import requests
+import sys
+import io
+from bs4 import BeautifulSoup
+
+# Fix Windows encoding
+if sys.platform == "win32":
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
+ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
+
+BASE_URL = "http://localhost:5000"
+
+def test_hierarchical_mode():
+ """Test hierarchical search mode."""
+ print("=" * 80)
+ print("TEST MODE HIÉRARCHIQUE APRÈS CORRECTION")
+ print("=" * 80)
+ print()
+
+ query = "What is the Turing test?"
+ print(f"Query: {query}")
+ print(f"Mode: hierarchical")
+ print("-" * 80)
+
+ try:
+ response = requests.get(
+ f"{BASE_URL}/search",
+ params={"q": query, "mode": "hierarchical", "limit": 5, "sections_limit": 3},
+ timeout=10
+ )
+
+ if response.status_code != 200:
+ print(f"❌ HTTP Error: {response.status_code}")
+ return
+
+ html = response.text
+
+ # Check if hierarchical mode is active
+ if "hiérarchique" in html.lower():
+ print("✅ Mode hiérarchique détecté")
+ else:
+ print("❌ Mode hiérarchique non détecté")
+
+ # Check for results
+ if "Aucun résultat" in html:
+ print("❌ Aucun résultat trouvé")
+ print()
+
+ # Check for fallback reason
+ if "fallback" in html.lower():
+ print("Raison de fallback présente dans la réponse")
+
+ # Print some debug info
+ if "passage" in html.lower():
+ print("Le mot 'passage' est présent")
+ if "section" in html.lower():
+ print("Le mot 'section' est présent")
+
+ return
+
+ # Count passages
+ passage_count = html.count("passage-card") + html.count("chunk-item")
+ print(f"✅ Nombre de cartes de passage trouvées: {passage_count}")
+
+ # Count sections
+ section_count = html.count("section-group")
+ print(f"✅ Nombre de groupes de sections: {section_count}")
+
+ # Check for section headers
+ if "section-header" in html:
+ print("✅ Headers de section présents")
+
+ # Check for Summary text
+ if "summary-text" in html or "Résumé" in html:
+ print("✅ Textes de résumé présents")
+
+ # Check for concepts
+ if "Concepts" in html or "concepts" in html:
+ print("✅ Concepts affichés")
+
+ print()
+ print("=" * 80)
+ print("RÉSULTAT: Mode hiérarchique fonctionne!" if passage_count > 0 else "PROBLÈME: Aucun passage trouvé")
+ print("=" * 80)
+
+ except Exception as e:
+ print(f"❌ ERROR: {e}")
+ import traceback
+ traceback.print_exc()
+
+if __name__ == "__main__":
+ test_hierarchical_mode()
diff --git a/generations/library_rag/test_summary_dropdown.py b/generations/library_rag/test_summary_dropdown.py
new file mode 100644
index 0000000..ab8cde6
--- /dev/null
+++ b/generations/library_rag/test_summary_dropdown.py
@@ -0,0 +1,111 @@
+"""Test script for Summary mode in dropdown integration."""
+
+import requests
+import sys
+import io
+
+# Fix Windows encoding
+if sys.platform == "win32":
+ sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
+ sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8')
+
+BASE_URL = "http://localhost:5000"
+
+def test_summary_dropdown():
+ """Test the summary mode via dropdown in /search endpoint."""
+ print("=" * 80)
+ print("TESTING SUMMARY MODE IN DROPDOWN")
+ print("=" * 80)
+ print()
+
+ # Test queries with mode=summary
+ test_cases = [
+ {
+ "query": "What is the Turing test?",
+ "expected_doc": "Haugeland",
+ "expected_icon": "🟣",
+ },
+ {
+ "query": "Can virtue be taught?",
+ "expected_doc": "Platon",
+ "expected_icon": "🟢",
+ },
+ {
+ "query": "What is pragmatism according to Peirce?",
+ "expected_doc": "Tiercelin",
+ "expected_icon": "🟡",
+ },
+ ]
+
+ for i, test in enumerate(test_cases, 1):
+ print(f"Test {i}/3: '{test['query']}' (mode=summary)")
+ print("-" * 80)
+
+ try:
+ response = requests.get(
+ f"{BASE_URL}/search",
+ params={"q": test["query"], "limit": 5, "mode": "summary"},
+ timeout=10
+ )
+
+ if response.status_code == 200:
+ # Check if expected document icon is in response
+ if test["expected_icon"] in response.text:
+ print(f"✅ PASS - Found {test['expected_doc']} icon {test['expected_icon']}")
+ else:
+ print(f"❌ FAIL - Expected icon {test['expected_icon']} not found")
+
+ # Check if summary badge is present
+ if "Résumés uniquement" in response.text or "90% visibilité" in response.text:
+ print("✅ PASS - Summary mode badge displayed")
+ else:
+ print("❌ FAIL - Summary mode badge not found")
+
+ # Check if results are present
+ if "passage" in response.text and "trouvé" in response.text:
+ print("✅ PASS - Results displayed")
+ else:
+ print("❌ FAIL - No results found")
+
+ # Check for concepts
+ if "Concepts" in response.text or "concept" in response.text:
+ print("✅ PASS - Concepts displayed")
+ else:
+ print("⚠️ WARN - Concepts may not be displayed")
+
+ else:
+ print(f"❌ FAIL - HTTP {response.status_code}")
+
+ except Exception as e:
+ print(f"❌ ERROR - {e}")
+
+ print()
+
+ # Test that mode dropdown has summary option
+ print("Test 4/4: Summary option in mode dropdown")
+ print("-" * 80)
+ try:
+ response = requests.get(f"{BASE_URL}/search", timeout=10)
+ if response.status_code == 200:
+ if 'value="summary"' in response.text:
+ print("✅ PASS - Summary option present in dropdown")
+ else:
+ print("❌ FAIL - Summary option not found in dropdown")
+
+ if "90% visibilité" in response.text or "Résumés uniquement" in response.text:
+ print("✅ PASS - Summary option label correct")
+ else:
+ print("⚠️ WARN - Summary option label may be missing")
+ else:
+ print(f"❌ FAIL - HTTP {response.status_code}")
+ except Exception as e:
+ print(f"❌ ERROR - {e}")
+
+ print()
+ print("=" * 80)
+ print("DROPDOWN INTEGRATION TEST COMPLETE")
+ print("=" * 80)
+
+
+if __name__ == "__main__":
+ test_summary_dropdown()