mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2025-08-23 22:32:54 +08:00
Merge pull request #5483 from whybeyoung/main
fix: 修复function call数据集如果 function_call 值的为不合法json,异常提示且中断训练。 Former-commit-id: af8dfb58fd4bd123a76fa8f393cf928995ec91b9
This commit is contained in:
commit
944ae8780c
@ -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:
|
||||||
functions = []
|
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:
|
||||||
return [""]
|
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"]]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user