diff --git a/src/pipelines/saas/prompts/prompt_calls.py b/src/pipelines/saas/prompts/prompt_calls.py index 691a8b7..42e5a1a 100644 --- a/src/pipelines/saas/prompts/prompt_calls.py +++ b/src/pipelines/saas/prompts/prompt_calls.py @@ -899,7 +899,7 @@ def prompt_split_reimb_dates(date_range: str, filename: str) -> dict: prompt, model_id="sonnet_latest", filename=filename, - max_tokens=200, + max_tokens=500, cache=True, instruction=prompt_templates.SPLIT_REIMB_DATES_INSTRUCTION(), usage_label="SPLIT_REIMB_DATES", diff --git a/src/pipelines/shared/extraction/one_to_n_funcs.py b/src/pipelines/shared/extraction/one_to_n_funcs.py index f64a19a..81e1060 100644 --- a/src/pipelines/shared/extraction/one_to_n_funcs.py +++ b/src/pipelines/shared/extraction/one_to_n_funcs.py @@ -679,6 +679,13 @@ def split_reimb_dates(one_to_n_results: list, filename: str) -> list: llm_answer_final = prompt_calls.prompt_split_reimb_dates( date_range, filename ) + # Debug: print raw parsed LLM output + print(f"DEBUG split_reimb_dates - Index {index}:") + print(f" Input date_range: {date_range}") + print(f" Parsed LLM output: {llm_answer_final} (type: {type(llm_answer_final)})") + if isinstance(llm_answer_final, dict): + print(f" start_date: {llm_answer_final.get('start_date')}") + print(f" end_date: {llm_answer_final.get('end_date')}") # Update the specific record with parsed dates if llm_answer_final and isinstance(llm_answer_final, dict): if "start_date" in llm_answer_final: diff --git a/src/prompts/prompt_templates.py b/src/prompts/prompt_templates.py index afb0b48..6672304 100644 --- a/src/prompts/prompt_templates.py +++ b/src/prompts/prompt_templates.py @@ -2010,7 +2010,7 @@ def EFFECTIVE_DATE_FIX_PROMPT() -> Tuple[str, Callable[[str], dict]]: def SPLIT_REIMB_DATES_INSTRUCTION() -> str: """Static instruction for SPLIT_REIMB_DATES prompt caching.""" - return """[OBJECTIVE] + return f"""[OBJECTIVE] Extract start and end dates from a date range string and return them in YYYY/MM/DD format. [RULES] @@ -2034,17 +2034,23 @@ Extract start and end dates from a date range string and return them in YYYY/MM/ 5. If only one date is present: - Assume it is the start_date and set end_date as "N/A" -6. If no extractable dates are found in the text: +6. If multiple date ranges are present (separated by commas, e.g., "Effective 5/1/2018 - 4/30/2019, Effective 5/1/2019 - 4/30/2020"): + - Extract the FIRST (earliest) date range only + - Use the start_date from the first range and end_date from the first range + - Ignore all subsequent date ranges + +7. If no extractable dates are found in the text: - Return "N/A" for both start_date and end_date [OUTPUT FORMAT] -Return the dates in the following JSON format: -{ +Return ONLY the JSON dictionary with no explanatory text. Use the following format: +{{ "start_date": "YYYY/MM/DD", "end_date": "YYYY/MM/DD" -} +}} -Note: Use "N/A" for dates that cannot be determined or extracted from the input text.""" +Note: Use "N/A" for dates that cannot be determined or extracted from the input text. +{JSON_DICT_FORMAT_INSTRUCTIONS}""" def SPLIT_REIMB_DATES(date_range: str) -> Tuple[str, Callable[[str], dict]]: