🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
rm unnecessary condition
yzlind5c3c5a14747
diff --git a/metagpt/tools/tool_convert.py b/metagpt/tools/tool_convert.pyindex 7d7374fde..829269b1b 100644--- a/metagpt/tools/tool_convert.py+++ b/metagpt/tools/tool_convert.py@@ -32,15 +32,8 @@ def convert_code_to_tool_schema(obj, include: list[str] = None) -> dict:def convert_code_to_tool_schema_ast(code: str) -> list[dict]:"""Converts a code string to a list of tool schemas by parsing the code with AST"""- # Modify the AST nodes to include parent references, enabling to attach methods to their class- def add_parent_references(node, parent=None):- for child in ast.iter_child_nodes(node):- child.parent = parent- add_parent_references(child, parent=node)-visitor = CodeVisitor(code)parsed_code = ast.parse(code)- add_parent_references(parsed_code)visitor.visit(parsed_code)return visitor.get_tool_schemas()@@ -108,7 +101,7 @@ class CodeVisitor(ast.NodeVisitor):self._visit_function(node)def _visit_function(self, node):- if isinstance(node.parent, ast.ClassDef) or node.name.startswith("_"):+ if node.name.startswith("_"):returnfunction_schemas = self._get_function_schemas(node)function_schemas["code"] = ast.get_source_segment(self.source_code, node)