From daa13094667b821811cc6544096d2b85dee59851 Mon Sep 17 00:00:00 2001 From: ybyang Date: Thu, 19 Sep 2024 14:54:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dfunction=20call?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=A6=82=E6=9E=9C=20function=5Fcall?= =?UTF-8?q?=20=E5=80=BC=E7=9A=84=E4=B8=BA=E4=B8=8D=E5=90=88=E6=B3=95json?= =?UTF-8?q?=EF=BC=8C=E5=BC=82=E5=B8=B8=E6=8F=90=E7=A4=BA=E4=B8=94=E4=B8=AD?= =?UTF-8?q?=E6=96=AD=E8=AE=AD=E7=BB=83=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 953e1a0fb226e63b797cab0007c53d3ebc6456bb --- src/llamafactory/data/formatter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/llamafactory/data/formatter.py b/src/llamafactory/data/formatter.py index f8b3979a..15401fbb 100644 --- a/src/llamafactory/data/formatter.py +++ b/src/llamafactory/data/formatter.py @@ -113,7 +113,7 @@ class FunctionFormatter(Formatter): functions.append((tool_call["name"], json.dumps(tool_call["arguments"], ensure_ascii=False))) except json.JSONDecodeError: - functions = [] + raise RuntimeError("Not Valid functions Message {}".format(str([content]))) elements = [] for name, arguments in functions: @@ -141,7 +141,8 @@ class ToolFormatter(Formatter): tools = json.loads(content) return [self.tool_utils.tool_formatter(tools) if len(tools) != 0 else ""] except json.JSONDecodeError: - return [""] + raise RuntimeError("Not Valid functions Message {}".format(str([content]))) + @override def extract(self, content: str) -> Union[str, List["FunctionCall"]]: