From 01c8c6c4195eff3a0ee6b736a54c3e5a517b89d3 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 4 Sep 2024 17:13:34 +0100 Subject: [PATCH] Add a warning to the chat template docs about the tool_calls format (#33277) * Add a warning to the chat template docs * Add a warning to the chat template docs * Add a warning to the chat template docs --- docs/source/en/chat_templating.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/source/en/chat_templating.md b/docs/source/en/chat_templating.md index 6564912a85..01ff5fed46 100644 --- a/docs/source/en/chat_templating.md +++ b/docs/source/en/chat_templating.md @@ -441,6 +441,12 @@ tool_call = {"name": "get_current_temperature", "arguments": {"location": "Paris messages.append({"role": "assistant", "tool_calls": [{"type": "function", "function": tool_call}]}) ``` + + +If you're familiar with the OpenAI API, you should pay attention to an important difference here - the `tool_call` is +a dict, but in the OpenAI API it's a JSON string. Passing a string may cause errors or strange model behaviour! + + Now that we've added the tool call to the conversation, we can call the function and append the result to the conversation. Since we're just using a dummy function for this example that always returns 22.0, we can just append