From 00de0a4be8c0912fc05683c874597f135e4259bd Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 10 Sep 2025 17:15:03 +0800 Subject: [PATCH] Handle backtick-wrapped brackets in extraction result parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support `( and `( start patterns * Support )` and )` end patterns * Graceful fallback to warning logs * Strip 2 chars for backtick variants * Maintain existing bracket logic --- lightrag/operate.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lightrag/operate.py b/lightrag/operate.py index c2ad079b..745b042c 100644 --- a/lightrag/operate.py +++ b/lightrag/operate.py @@ -881,15 +881,21 @@ async def _process_extraction_result( if record.startswith("(") or record.startswith("("): record = record[1:] else: - logger.warning( - f"{chunk_key}: Record starting bracket can not be found in extraction result" - ) + if record.startswith("`(") or record.startswith("`("): + record = record[2:] + else: + logger.warning( + f"{chunk_key}: Record starting bracket can not be found in extraction result" + ) if record.endswith(")") or record.endswith(")"): record = record[:-1] else: - logger.warning( - f"{chunk_key}: Record ending bracket can not be found in extraction result" - ) + if record.endswith(")`") or record.endswith(")`"): + record = record[:-2] + else: + logger.warning( + f"{chunk_key}: Record ending bracket can not be found in extraction result" + ) record = record.strip() if record is None: