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.