From f05c2c9f8b20922f83d55d823383b98415cf1130 Mon Sep 17 00:00:00 2001 From: Emil Sedgh Date: Fri, 6 Oct 2023 17:12:04 -0700 Subject: [PATCH] Consider function calling roles and messages valid (#765) --- examples/Chat_finetuning_data_prep.ipynb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/Chat_finetuning_data_prep.ipynb b/examples/Chat_finetuning_data_prep.ipynb index a0318d55..3c0f7fd3 100644 --- a/examples/Chat_finetuning_data_prep.ipynb +++ b/examples/Chat_finetuning_data_prep.ipynb @@ -123,14 +123,16 @@ " if \"role\" not in message or \"content\" not in message:\n", " format_errors[\"message_missing_key\"] += 1\n", " \n", - " if any(k not in (\"role\", \"content\", \"name\") for k in message):\n", + " if any(k not in (\"role\", \"content\", \"name\", \"function_call\") for k in message):\n", " format_errors[\"message_unrecognized_key\"] += 1\n", " \n", - " if message.get(\"role\", None) not in (\"system\", \"user\", \"assistant\"):\n", + " if message.get(\"role\", None) not in (\"system\", \"user\", \"assistant\", \"function\"):\n", " format_errors[\"unrecognized_role\"] += 1\n", " \n", " content = message.get(\"content\", None)\n", - " if not content or not isinstance(content, str):\n", + " function_call = message.get(\"function_call\", None)\n", + " \n", + " if (not content and not function_call) or not isinstance(content, str):\n", " format_errors[\"missing_content\"] += 1\n", " \n", " if not any(message.get(\"role\", None) == \"assistant\" for message in messages):\n",