Merge pull request #5483 from whybeyoung/main

fix: 修复function call数据集如果 function_call 值的为不合法json,异常提示且中断训练。
This commit is contained in:
hoshi-hiyouga 2024-09-19 17:01:52 +08:00 committed by GitHub
commit af8dfb58fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -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("Invalid JSON format in function message: {}".format(str([content]))) # flat string
elements = []
for name, arguments in functions:
@ -141,7 +141,7 @@ 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("Invalid JSON format in tool description: {}".format(str([content]))) # flat string
@override
def extract(self, content: str) -> Union[str, List["FunctionCall"]]: