#Tool calls vs tool messages

1 messages · Page 1 of 1 (latest)

astral vine
#

What are tool messages as opposed to tool calls? Can you give an example of both?

fast oakBOT
#

Hi @astral vine. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

In the context of OpenAI's chat models, a tool call is a request made by the assistant (the AI model) to use a specific tool or function. This request is made in the form of a JSON document that includes the name of the function and the arguments to be used with the function.

On the other hand, a tool message is a response to a tool call. It is a message that contains the result of the function call. It is important to note that an assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'.

Here is an example of a tool call:

assistant_message = {
    "role": "assistant",
    "tool_calls": [{
        "id": "call_auTHoCmlzOHNdwQuO1NXtOZT", 
        "function": {
            "name": "ask_user_clarifying_question",
            "arguments": {
                "question": "What is the weather like?",
                "choices": ["Sunny", "Rainy", "Cloudy"]
            }
        }, 
        "type": "function"
    }]
}
messages.append(assistant_message)

And here is an example of a tool message, which is a response to the tool call:

tool_message = {
    "tool_call_id": "call_auTHoCmlzOHNdwQuO1NXtOZT",
    "role": "tool",
    "name": "ask_user_clarifying_question",
    "content": "Sunny"
}
messages.append(tool_message)

In this example, the assistant makes a tool call to ask a clarifying question to the user. The tool message is the response to this tool call, which in this case is "Sunny".

#

@astral vine kapa.ai is still learning and improving, please let us know how it did by reacting below

nova rose
#

Hi