mirror of
https://github.com/microsoft/graphrag.git
synced 2025-11-05 12:23:27 +00:00
* initialize config with LocalSearchConfig and GlobalSearchConfig * init_content LocalSearchConfig and GlobalSearchConfig * rollback MAP_SYSTEM_PROMPT * Small changes before merging. Notebook rollback * Semver --------- Co-authored-by: glide-the <2533736852@qq.com>
28 lines
719 B
Python
28 lines
719 B
Python
# Copyright (c) 2024 Microsoft Corporation.
|
|
# Licensed under the MIT License
|
|
|
|
"""JSON cleaning and formatting utilities."""
|
|
|
|
|
|
def clean_up_json(json_str: str):
|
|
"""Clean up json string."""
|
|
json_str = (
|
|
json_str.replace("\\n", "")
|
|
.replace("\n", "")
|
|
.replace("\r", "")
|
|
.replace('"[{', "[{")
|
|
.replace('}]"', "}]")
|
|
.replace("\\", "")
|
|
.strip()
|
|
)
|
|
|
|
# Remove JSON Markdown Frame
|
|
if json_str.startswith("```json"):
|
|
json_str = json_str[len("```json") :]
|
|
if json_str.startswith("json"):
|
|
json_str = json_str[len("json") :]
|
|
if json_str.endswith("```"):
|
|
json_str = json_str[: len(json_str) - len("```")]
|
|
|
|
return json_str
|