From a7a32b9092ff5e8adbd24d3d678c193c4b7bfeb6 Mon Sep 17 00:00:00 2001 From: ppanchigar Date: Tue, 3 Feb 2026 11:01:47 -0600 Subject: [PATCH] fix: complete Phase 3 - replace remaining universal_json_load calls in code_funcs.py - Line 498: Changed from universal_json_load to use _parser from FILL_BILL_TYPE tuple - Line 856: Updated GROUPER_BREAKOUT call to unpack tuple and use grouper_parser - Removed unused GROUPER_QUESTIONS variable (fields now in INSTRUCTION function for caching) - All universal_json_load calls in code_funcs.py have been replaced - Phase 3 is now 100% complete --- src/codes/code_funcs.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/codes/code_funcs.py b/src/codes/code_funcs.py index 47d410c..c8a4a10 100644 --- a/src/codes/code_funcs.py +++ b/src/codes/code_funcs.py @@ -495,7 +495,7 @@ def fill_bill_type( cache=True, instruction=prompt_templates.FILL_BILL_TYPE_INSTRUCTION(), ) - llm_answer_final = string_utils.universal_json_load(llm_answer_raw) + llm_answer_final = _parser(llm_answer_raw) # Second attempt: Service term + reimbursement term + exhibit context (if first attempt failed and context available) if not llm_answer_final and exhibit_text: @@ -818,9 +818,6 @@ def grouper_breakout(results_with_code: pd.DataFrame): """ # try grouper fields again if they are empty and grouper_cd is not empty answer_dicts_with_code = results_with_code.to_dict(orient="records") - GROUPER_QUESTIONS = FieldSet( - file_path=config.FIELD_JSON_PATH, field_type="grouper_breakout" - ).print_prompt_dict() # Separate dicts that need grouper breakout from those that don't needs_breakout = [] @@ -840,10 +837,9 @@ def grouper_breakout(results_with_code: pd.DataFrame): # Parallelize LLM calls for rows that need breakout def process_grouper_breakout(answer_dict): - grouper_breakout_prompt = prompt_templates.GROUPER_BREAKOUT( + grouper_breakout_prompt, grouper_parser = prompt_templates.GROUPER_BREAKOUT( answer_dict.get("SERVICE_TERM", ""), answer_dict.get("REIMB_TERM", ""), - GROUPER_QUESTIONS, ) claude_answer_raw = llm_utils.invoke_claude( grouper_breakout_prompt, @@ -853,7 +849,7 @@ def grouper_breakout(results_with_code: pd.DataFrame): instruction=prompt_templates.GROUPER_BREAKOUT_INSTRUCTION(), ) try: - grouper_answer = string_utils.universal_json_load(claude_answer_raw) + grouper_answer = grouper_parser(claude_answer_raw) except Exception as e: grouper_answer = {"GROUPER_TYPE": e}