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
This commit is contained in:
ppanchigar
2026-02-03 11:01:47 -06:00
parent 2e307347fd
commit a7a32b9092
+3 -7
View File
@@ -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}