From 35aef8b28761d787d42e548567fc6689a1502ab5 Mon Sep 17 00:00:00 2001 From: hiyouga Date: Thu, 18 Jan 2024 16:01:07 +0800 Subject: [PATCH] fix function formatter --- src/llmtuner/data/formatter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/llmtuner/data/formatter.py b/src/llmtuner/data/formatter.py index ce7b2819..f1c35308 100644 --- a/src/llmtuner/data/formatter.py +++ b/src/llmtuner/data/formatter.py @@ -44,9 +44,9 @@ class FunctionFormatter: def __call__(self, content: str) -> List[Union[str, Dict[str, str]]]: try: function = json.loads(content) - name = json.dumps(function["name"], ensure_ascii=False) + name = function["name"] arguments = json.dumps(function["arguments"], ensure_ascii=False) - except json.JSONDecodeError: + except Exception: name, arguments = "", "" elements = [] @@ -98,5 +98,5 @@ class ToolFormatter: if self.type == "default": return [self._default(tools)] - except json.JSONDecodeError: + except Exception: return [""]