Alonso Guevara ce462515d8
Local search llm params (#533)
* 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>
2024-07-15 13:01:56 -06:00

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