mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 05:10:38 +08:00
fallback to try_fix_yaml
This commit is contained in:
@ -290,7 +290,6 @@ def _fix_key_value(key: str, value: str):
|
|||||||
|
|
||||||
def load_yaml(response_text: str) -> dict:
|
def load_yaml(response_text: str) -> dict:
|
||||||
response_text = response_text.removeprefix('```yaml').rstrip('`')
|
response_text = response_text.removeprefix('```yaml').rstrip('`')
|
||||||
response_text = response_text.strip().rstrip().removeprefix('{').removesuffix('}')
|
|
||||||
try:
|
try:
|
||||||
data = yaml.safe_load(response_text)
|
data = yaml.safe_load(response_text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -326,7 +325,15 @@ def try_fix_yaml(response_text: str) -> dict:
|
|||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return data
|
|
||||||
|
# thrid fallback - try to remove leading and trailing curly brackets
|
||||||
|
response_text_copy = response_text.strip().rstrip().removeprefix('{').removesuffix('}')
|
||||||
|
try:
|
||||||
|
data = yaml.safe_load(response_text_copy,)
|
||||||
|
get_logger().info(f"Successfully parsed AI prediction after removing curly brackets")
|
||||||
|
return data
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def set_custom_labels(variables):
|
def set_custom_labels(variables):
|
||||||
|
Reference in New Issue
Block a user