fix function formatter

This commit is contained in:
hiyouga 2024-01-18 16:01:07 +08:00
parent ddd48ce8ab
commit 35aef8b287
1 changed files with 3 additions and 3 deletions

View File

@ -44,9 +44,9 @@ class FunctionFormatter:
def __call__(self, content: str) -> List[Union[str, Dict[str, str]]]: def __call__(self, content: str) -> List[Union[str, Dict[str, str]]]:
try: try:
function = json.loads(content) function = json.loads(content)
name = json.dumps(function["name"], ensure_ascii=False) name = function["name"]
arguments = json.dumps(function["arguments"], ensure_ascii=False) arguments = json.dumps(function["arguments"], ensure_ascii=False)
except json.JSONDecodeError: except Exception:
name, arguments = "", "" name, arguments = "", ""
elements = [] elements = []
@ -98,5 +98,5 @@ class ToolFormatter:
if self.type == "default": if self.type == "default":
return [self._default(tools)] return [self._default(tools)]
except json.JSONDecodeError: except Exception:
return [""] return [""]