From f20064a5786540f7364a5cf60b2fa237af3ef4e5 Mon Sep 17 00:00:00 2001 From: eukub Date: Thu, 28 Dec 2023 20:10:33 +0300 Subject: [PATCH] =?UTF-8?q?=D1=81hanged=20concatenation=20of=20strings=20t?= =?UTF-8?q?o=20f-strings=20to=20improve=20readability=20and=20unify=20with?= =?UTF-8?q?=20the=20rest=20of=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- metagpt/actions/action_node.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/metagpt/actions/action_node.py b/metagpt/actions/action_node.py index 3529942c3..e44e5e96e 100644 --- a/metagpt/actions/action_node.py +++ b/metagpt/actions/action_node.py @@ -195,10 +195,7 @@ class ActionNode: def tagging(self, text, schema, tag="") -> str: if not tag: return text - if schema == "json": - return f"[{tag}]\n" + text + f"\n[/{tag}]" - else: # markdown - return f"[{tag}]\n" + text + f"\n[/{tag}]" + return f"[{tag}]\n{text}\n[/{tag}]" def _compile_f(self, schema, mode, tag, format_func, kv_sep) -> str: nodes = self.to_dict(format_func=format_func, mode=mode) @@ -230,7 +227,7 @@ class ActionNode: schema="markdown": 编译context, example(markdown), instruction(markdown), constraint, action """ if schema == "raw": - return context + "\n\n## Actions\n" + LANGUAGE_CONSTRAINT + "\n" + self.instruction + return f"{context}\n\n## Actions\n{LANGUAGE_CONSTRAINT}\n{self.instruction}" # FIXME: json instruction会带来格式问题,如:"Project name": "web_2048 # 项目名称使用下划线", # compile example暂时不支持markdown