Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

rollback format

lidanyang41c507aa6e00
diff --git a/metagpt/utils/common.py b/metagpt/utils/common.py
index fac6a478d..8f8edbc6d 100644
--- a/metagpt/utils/common.py
+++ b/metagpt/utils/common.py
@@ -24,11 +24,7 @@ def check_cmd_exists(command) -> int:
if platform.system().lower() == "windows":
check_command = "where " + command
else:
- check_command = (
- "command -v "
- + command
- + ' >/dev/null 2>&1 || { echo >&2 "no mermaid"; exit 1; }'
- )
+ check_command = "command -v " + command + ' >/dev/null 2>&1 || { echo >&2 "no mermaid"; exit 1; }'
result = os.system(check_command)
return result
@@ -138,11 +134,7 @@ class OutputParser:
typing = typing_define[0]
else:
typing = typing_define
- if (
- typing == List[str]
- or typing == List[Tuple[str, str]]
- or typing == List[List[str]]
- ):
+ if typing == List[str] or typing == List[Tuple[str, str]] or typing == List[List[str]]:
# 尝试解析list
try:
content = cls.parse_file_list(text=content)
@@ -159,9 +151,7 @@ class OutputParser:
return parsed_data
@classmethod
- def extract_struct(
- cls, text: str, data_type: Union[type(list), type(dict)]
- ) -> Union[list, dict]:
+ def extract_struct(cls, text: str, data_type: Union[type(list), type(dict)]) -> Union[list, dict]:
"""Extracts and parses a specified type of structure (dictionary or list) from the given text.
The text only contains a list or dictionary, which may have nested structures.
@@ -203,9 +193,7 @@ class OutputParser:
raise ValueError(f"The extracted structure is not a {data_type}.")
except (ValueError, SyntaxError) as e:
- raise Exception(
- f"Error while extracting and parsing the {data_type}: {e}"
- )
+ raise Exception(f"Error while extracting and parsing the {data_type}: {e}")
else:
logger.error(f"No {data_type} found in the text.")
return [] if data_type is list else {}