From 0952014fa9bcb28bed6f8b6c915d70daa2a83327 Mon Sep 17 00:00:00 2001 From: Alonso Guevara Date: Wed, 25 Sep 2024 17:11:49 -0600 Subject: [PATCH] Fix issue 1173 - Nested json parsing (#1218) --- .semversioner/next-release/patch-20240925225104981872.json | 4 ++++ graphrag/llm/openai/utils.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .semversioner/next-release/patch-20240925225104981872.json diff --git a/.semversioner/next-release/patch-20240925225104981872.json b/.semversioner/next-release/patch-20240925225104981872.json new file mode 100644 index 0000000000..707eb753a9 --- /dev/null +++ b/.semversioner/next-release/patch-20240925225104981872.json @@ -0,0 +1,4 @@ +{ + "type": "patch", + "description": "Fix nested json parsing" +} \ No newline at end of file diff --git a/graphrag/llm/openai/utils.py b/graphrag/llm/openai/utils.py index 5d683951b1..64b7118d9b 100644 --- a/graphrag/llm/openai/utils.py +++ b/graphrag/llm/openai/utils.py @@ -104,7 +104,7 @@ def try_parse_json_object(input: str) -> tuple[str, dict]: return input, result _pattern = r"\{(.*)\}" - _match = re.search(_pattern, input) + _match = re.search(_pattern, input, re.DOTALL) input = "{" + _match.group(1) + "}" if _match else input # Clean up json string.