@@ -822,6 +822,13 @@ async def _parse_extraction_result(
822822 maybe_nodes = defaultdict (list )
823823 maybe_edges = defaultdict (list )
824824
825+ # Preventive fix: when tuple_delimiter is <|>, fix LLM output instability issues
826+ if context_base ["tuple_delimiter" ] == "<|>" :
827+ # 1. Convert <||> to <|>
828+ extraction_result = extraction_result .replace ("<||>" , "<|>" )
829+ # 2. Convert < | > to <|>
830+ extraction_result = extraction_result .replace ("< | >" , "<|>" )
831+
825832 # Parse the extraction result using the same logic as in extract_entities
826833 records = split_string_by_multi_markers (
827834 extraction_result ,
@@ -1729,6 +1736,13 @@ async def _process_extraction_result(
17291736 maybe_nodes = defaultdict (list )
17301737 maybe_edges = defaultdict (list )
17311738
1739+ # Preventive fix: when tuple_delimiter is <|>, fix LLM output instability issues
1740+ if context_base ["tuple_delimiter" ] == "<|>" :
1741+ # 1. Convert <||> to <|>
1742+ result = result .replace ("<||>" , "<|>" )
1743+ # 2. Convert < | > to <|>
1744+ result = result .replace ("< | >" , "<|>" )
1745+
17321746 records = split_string_by_multi_markers (
17331747 result ,
17341748 [context_base ["record_delimiter" ], context_base ["completion_delimiter" ]],
0 commit comments