From 86a9347cb0e55f79bc354ac1e06043c2601b93eb Mon Sep 17 00:00:00 2001 From: Katon Minhas Date: Wed, 4 Feb 2026 12:04:48 -0500 Subject: [PATCH] Fix prompt to ensure list-of-dicts-of-str --- src/prompts/prompt_templates.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/prompts/prompt_templates.py b/src/prompts/prompt_templates.py index afb0b48..bf90be3 100644 --- a/src/prompts/prompt_templates.py +++ b/src/prompts/prompt_templates.py @@ -1442,17 +1442,20 @@ Examples: Briefly explain your reasoning. After your explanation, include the heading "FINAL PROVIDER INFO:" followed by a properly formatted JSON array with your final output. -[EXTRACTION AND FORMATTING INSTRUCTIONS] +[EXTRACTION INSTRUCTIONS] - First, analyze the text thoroughly and identify all provider entities - Return TIN and NPIs that are found on the page even if they aren't explicitly labeled as such. - If the table contains multiple name columns (e.g. 'System Name' and 'Facility Name'), YOU MUST extract the specific 'Facility Name' or 'Hospital Name' column. - IMPORTANT VALIDATION REQUIREMENTS: * TIN must be exactly 9 digits (no more, no less) * NPI must be exactly 10 digits (no more, no less) - * Double-check the digit count for each TIN and NPI before including them in the response -- In your response, include ONLY ONE SINGLE properly formatted JSON array, after your explanation -- Each provider must be an object within this array + * CAREFULLY double-check the digit count for each TIN and NPI before including them in the response + +[FORMATTING INSTRUCTIONS] +- In your response, include ONLY ONE SINGLE properly formatted JSON List-of-Dicts-of-Str, after your explanation +- Each provider must be an object (DICT) within this array - All provider objects must have these exact keys: "TIN", "NPI", "NAME" +- ALl dict values must be strings - if there are multiple different TINs or NPIs for an identical NAME, put them in different dictionaries. - Use "N/A" for any missing values - A provider record is considered valid as long as either a TIN, NPI, or NAME is present. If any one or two of those fields are missing, use "N/A" for those fields. - Your final JSON array must begin with an opening bracket '[' and end with a closing bracket ']' @@ -1467,13 +1470,18 @@ FINAL PROVIDER INFO: "NPI": "1234567890", "NAME": "Main Provider Group" }, + { + "TIN": "124681012", + "NPI": "N/A", + "NAME": "Main Provider Group" + }, { "TIN": "987654321", - "NPI": null, + "NPI": "N/A, "NAME": "Dr. John Smith", }, { - "TIN": null, + "TIN": "N/A", "NPI": "1234567890", "NAME": "Jane Doe, CRNA" }