File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -618,7 +618,19 @@ def correct_item(data):
618618 return None
619619
620620 dehallu_res = [correct_item (item ) for item in operations ]
621- llm_operations = [item for item in dehallu_res if item ]
621+ dehalluded_operations = [item for item in dehallu_res if item ]
622+
623+ # deduplicate add objects
624+ add_texts = []
625+ llm_operations = []
626+ for item in dehalluded_operations :
627+ if item ["operation" ].lower () == "add" and "text" in item and item ["text" ]:
628+ if item ["text" ] in add_texts :
629+ continue
630+ llm_operations .append (item )
631+ add_texts .append (item ["text" ])
632+ elif item ["operation" ].lower () == "update" :
633+ llm_operations .append (item )
622634
623635 # Update takes precedence over add
624636 has_update = any (item .get ("operation" ).lower () == "update" for item in llm_operations )
You can’t perform that action at this time.
0 commit comments