/
Hagu5
/
ESG-Reporter
Обзор
Документация
Войти
/
Hagu5
/
ESG-Reporter
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
scripts/test_graph_compilation.py
87 строк
3 KB
RoyalemPoBashke
feat(rag): implement complete RAG system with hybrid search and GRI standards integration
29 май 2026, 19:35
29 май 2026, 19:35
e7d6b2b
Код
Авторство
О чём код?
"""Test script to verify RAG-enabled graph compiles without errors.""" import sys from pathlib import Path # Add project root to path sys.path.insert(0, str(Path(__file__).parent.parent)) from esg_reporter.graph.builder import build_graph, get_initial_state def test_graph_compilation(): """Test that the graph compiles successfully.""" print("Testing graph compilation...") try: # Build graph graph = build_graph(use_checkpointer=False) print("[OK] Graph compiled successfully") # Test initial state creation initial_state = get_initial_state( company_name="Test Company", reporting_year=2024, raw_esg_notes="Test ESG notes for compilation check.", target_standard="GRI", max_revisions=2, ) print("[OK] Initial state created successfully") # Verify RAG fields are present rag_fields = [ "rag_collection_id", "rag_initialized", "writer_retrieved_context", "fact_checker_retrieved_context", "critic_retrieved_context", "compliance_retrieved_context", "writer_retrieval_metadata", "fact_checker_retrieval_metadata", "critic_retrieval_metadata", "compliance_retrieval_metadata", ] for field in rag_fields: if field not in initial_state: print(f"[FAIL] Missing RAG field: {field}") return False print("[OK] All RAG fields present in initial state") # Check graph nodes expected_nodes = [ "init_rag", "writer_retrieval", "fact_checker_retrieval", "critic_retrieval", "compliance_retrieval", "writer", "fact_checker", "critic", "compliance_officer", "review_aggregator", "finalize", ] graph_nodes = list(graph.nodes.keys()) for node in expected_nodes: if node not in graph_nodes: print(f"[FAIL] Missing graph node: {node}") return False print("[OK] All expected nodes present in graph") print(f"\nGraph nodes: {', '.join(graph_nodes)}") return True except Exception as e: print(f"[FAIL] Graph compilation failed: {e}") import traceback traceback.print_exc() return False if __name__ == "__main__": success = test_graph_compilation() sys.exit(0 if success else 1)