From 6a21488486ddee1e3a7c9b4f7c6657e285ee4f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=A3=92=E6=A3=92?= Date: Wed, 13 Sep 2023 22:59:48 +0800 Subject: [PATCH] deleted assert statements in function and correct function name. --- metagpt/actions/clone_function.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/metagpt/actions/clone_function.py b/metagpt/actions/clone_function.py index 377c35de4..cf7d22f04 100644 --- a/metagpt/actions/clone_function.py +++ b/metagpt/actions/clone_function.py @@ -42,13 +42,12 @@ class CloneFunction(WriteCode): prompt = CLONE_PROMPT.format(source_code=source_code, template_func=template_func) logger.info(f"query for CloneFunction: \n {prompt}") code = await self.write_code(prompt) - assert 'def' in code logger.info(f'CloneFunction code is \n {highlight(code)}') return code -def run_fucntion_code(func_code: str, func_name: str, *args, **kwargs): - """执行函数类生成代码""" +def run_function_code(func_code: str, func_name: str, *args, **kwargs): + """Run function code from string code.""" try: locals_ = {} exec(func_code, locals_) @@ -58,9 +57,9 @@ def run_fucntion_code(func_code: str, func_name: str, *args, **kwargs): return "", traceback.format_exc() -def run_fucntion_script(code_script_path: str, func_name: str, *args, **kwargs): - """从脚本中载入函数进行执行""" +def run_function_script(code_script_path: str, func_name: str, *args, **kwargs): + """Run function code from script.""" if isinstance(code_script_path, str): code_path = Path(code_script_path) code = code_path.read_text(encoding='utf-8') - return run_fucntion_code(code, func_name, *args, **kwargs) + return run_function_code(code, func_name, *args, **kwargs)