mirror of
https://github.com/hiyouga/LLaMA-Factory.git
synced 2026-05-28 02:48:54 +08:00
fix(data/converter): handle None tool_calls in OpenAI-style messages (#10455)
This commit is contained in:
@@ -257,8 +257,8 @@ class OpenAIDatasetConverter(DatasetConverter):
|
|||||||
content = message[self.dataset_attr.content_tag]
|
content = message[self.dataset_attr.content_tag]
|
||||||
|
|
||||||
if role in [self.dataset_attr.assistant_tag, self.dataset_attr.function_tag]:
|
if role in [self.dataset_attr.assistant_tag, self.dataset_attr.function_tag]:
|
||||||
if "tool_calls" in message and len(message["tool_calls"]) > 0:
|
if tool_calls := message.get("tool_calls"):
|
||||||
tool_calls_list = [tool["function"] for tool in message["tool_calls"]]
|
tool_calls_list = [tool["function"] for tool in tool_calls]
|
||||||
content = json.dumps(tool_calls_list, ensure_ascii=False)
|
content = json.dumps(tool_calls_list, ensure_ascii=False)
|
||||||
role = self.dataset_attr.function_tag
|
role = self.dataset_attr.function_tag
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user