# ============================================================================ # node_06_producing_report.py — Phase 6 (REAL — thin wrapper) # ============================================================================ # # Thin wrapper. Reads state, calls phase6_report.run_phase6_producing_report. # # Braun & Clarke 2006 Phase 6: # "The final phase is writing the report." (p. 93) # ============================================================================ try: from phase6_report import run_phase6_producing_report import pandas as pd _PHASE6_OK = True except Exception as _e: _PHASE6_OK = False _PHASE6_ERR = str(_e) def phase6_producing_report_node(state): iteration = state.get("iteration", 0) if not _PHASE6_OK: return { "phase6_producing_report": {"status": "error", "note": _PHASE6_ERR}, "steps": [{"step": iteration, "node": "phase6_producing_report", "action": "error", "detail": _PHASE6_ERR}], } phase5 = state.get("phase5_defining_naming") or {} def_rows = phase5.get("definition_rows") or [] def_df = pd.DataFrame(def_rows) if def_rows else pd.DataFrame() phase2 = state.get("phase2_initial_codes") or {} codes_rows = phase2.get("codes_table") or [] codes_df = pd.DataFrame(codes_rows) if codes_rows else pd.DataFrame() corpus = state.get("corpus") or [] corpus_desc = f"{len(corpus)} sentences" if corpus else "qualitative corpus" result = run_phase6_producing_report( definition_df=def_df, codes_df=codes_df, llm_key=state.get("llm_key", ""), llm_provider=state.get("llm_provider", "Mistral"), research_question=state.get("research_question", ""), reflexive_pos=state.get("reflexive_pos", ""), corpus_description=corpus_desc, ) return { "phase6_producing_report": { "status": "real" if not result["error"] else "error", "report_markdown": result["report_markdown"], "theme_count": result["theme_count"], "error": result["error"], }, "steps": [{"step": iteration, "node": "phase6_producing_report", "action": "produced analytic report", "detail": ( f"Report generated for {result['theme_count']} themes." if not result["error"] else result["error"] )}], }