From f556e352b82ed7ccf8e828abbac8aa485a2bdee8 Mon Sep 17 00:00:00 2001 From: Katon Minhas Date: Tue, 10 Jun 2025 21:43:34 +0000 Subject: [PATCH] Merged in hotfix/exhibit-linking-fix (pull request #569) Hotfix/exhibit linking fix * Add test * Add empty header condition * Remove test Approved-by: Alex Galarce --- fieldExtraction/src/preprocessing_funcs.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fieldExtraction/src/preprocessing_funcs.py b/fieldExtraction/src/preprocessing_funcs.py index 4c1178b..d4f6c84 100644 --- a/fieldExtraction/src/preprocessing_funcs.py +++ b/fieldExtraction/src/preprocessing_funcs.py @@ -299,18 +299,20 @@ def link_exhibit_pages(all_exhibit_headers, filename): # If literally identical, skip prompt if page_header.upper().strip() == previous_header.upper().strip(): exhibit_is_different = "N" + elif string_utils.is_empty(previous_header): + exhibit_is_different = "Y" + previous_header = page_header else: prompt = investment_prompts.EXHIBIT_LINKAGE(page_header, previous_header) claude_answer_raw = llm_utils.invoke_claude(prompt, config.MODEL_ID_CLAUDE35_SONNET, filename) exhibit_is_different = string_utils.extract_text_from_delimiters(claude_answer_raw, Delimiter.PIPE) - - # If the prompt has identified that the current exhibit is meaningfully different than the previous - if "Y" in exhibit_is_different: - final_exhibit_pages.append(page_num) - final_exhibit_headers[page_num] = page_header - previous_header = page_header - + + # If the prompt has identified that the current exhibit is meaningfully different than the previous + if "Y" in exhibit_is_different: + final_exhibit_pages.append(page_num) + final_exhibit_headers[page_num] = page_header + return final_exhibit_pages, final_exhibit_headers