Merged in refactor/one-to-n (pull request #702)

Refactor/one to n

* remove print

* Update logging for fsbreakout and grouper breakout

* Additional type hints

* updated special case primary

* Remove deprecated special case check

* OUTLIER_TERMS-->OUTLIER_TERM standardization

* Applied suggestion to fieldExtraction/src/prompts/investment_prompts.json
* update unit test

* Update Carveout IND and Default IND logic

* Split out exhibit-level lesser

* Bugfix

* update lesser of exhibit prompt

* Bugfix

* exhibit lesser of varible name bugfix

* Update exhibit lesser of passing

* Update Exhibit-level prompt template

* Shorten full_context prompt length if the questions are long

* Special case assignment index

* Resolve unit tests

* updated UC IND prompt

* Remove print

* update one-to-n unit test

* added dot based date example

* updated date fix prompt

* Merged in bugfix/json_error_and_unit_of_measure (pull request #708)

Bugfix/json error and unit of measure

* json parser fixes and prompt changes

* universal json load fixed

* json error fixed

* json error fixed 2

* Merged refactor/one-to-n into bugfix/json_error_and_unit_of_measure


Approved-by: Katon Minhas


Approved-by: Alex Galarce
This commit is contained in:
Katon Minhas
2025-09-24 15:56:27 +00:00
parent a9318cf1d2
commit 1050287397
25 changed files with 2924 additions and 3376 deletions
+4 -4
View File
@@ -201,7 +201,7 @@ def universal_json_load(string_dict: str):
take the last one positionally.
"""
# Try to match dictionary or list of dictionaries first
dict_matches = re.findall(r"\{.*\}|\[\s*?\{.*\}\s*?\]", string_dict, re.DOTALL)
dict_matches = re.findall(r"\{.*?\}|\[\s*?\{.*?\}\s*?\]", string_dict, re.DOTALL)
if dict_matches:
matched_str = dict_matches[-1] # Take the last match in the string
try:
@@ -219,6 +219,7 @@ def universal_json_load(string_dict: str):
raise ValueError(
f"JSON parsing failed: {e.msg} at position {e.pos}; Original string:\n{csv_safe_string}"
) from e
# If no dict pattern found, try to match list of strings
list_matches = re.findall(r"\[(.*?)\]", string_dict, re.DOTALL)
if list_matches:
@@ -226,9 +227,8 @@ def universal_json_load(string_dict: str):
try:
# Clean up the string list before parsing
cleaned_str = re.sub(r'(?<!\\)"', '"', matched_str) # Handle escaped quotes
cleaned_str = re.sub(
r"'", '"', cleaned_str
) # Replace single quotes with double quotes
cleaned_str = re.sub(r"'", '"', cleaned_str) # Replace single quotes with double quotes
return json.loads(cleaned_str)
except json.JSONDecodeError as e:
logging.error(f"Failed to parse list: {e}")