flat string

Former-commit-id: f2301305637aebc026895a7d4837e5def2c23159
This commit is contained in:
hoshi-hiyouga 2024-09-19 16:43:42 +08:00 committed by GitHub
parent e4d26efea9
commit 1ccc2d198e

View File

@ -113,7 +113,7 @@ class FunctionFormatter(Formatter):
functions.append((tool_call["name"], json.dumps(tool_call["arguments"], ensure_ascii=False))) functions.append((tool_call["name"], json.dumps(tool_call["arguments"], ensure_ascii=False)))
except json.JSONDecodeError: except json.JSONDecodeError:
raise RuntimeError("Invalid JSON format in function message: {}".format(content)) raise RuntimeError("Invalid JSON format in function message: {}".format(str([content]))) # flat string
elements = [] elements = []
for name, arguments in functions: for name, arguments in functions:
@ -141,7 +141,7 @@ class ToolFormatter(Formatter):
tools = json.loads(content) tools = json.loads(content)
return [self.tool_utils.tool_formatter(tools) if len(tools) != 0 else ""] return [self.tool_utils.tool_formatter(tools) if len(tools) != 0 else ""]
except json.JSONDecodeError: except json.JSONDecodeError:
raise RuntimeError("Invalid JSON format in tool description: {}".format(content)) raise RuntimeError("Invalid JSON format in tool description: {}".format(str([content]))) # flat string
@override @override
def extract(self, content: str) -> Union[str, List["FunctionCall"]]: def extract(self, content: str) -> Union[str, List["FunctionCall"]]: