fix function formatter

Former-commit-id: 35aef8b28761d787d42e548567fc6689a1502ab5
This commit is contained in:
hiyouga 2024-01-18 16:01:07 +08:00
parent 6e33982849
commit a9fe47a848

View File

@ -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 [""]