Issues with Tools use and Chat templates

#99
by pyrator - opened

The documentation appears to be incorrect.
When trying to create a multiply function
the response is {'name': 'multiply', 'parameters': {'a': 5, 'b': 2}}
Then when trying to add this as a tool_call to the chat for instance this snippet generates a TypeError: Object of type Undefined is not JSON serializable
messages.append({"role": "assistant", "tool_calls": [{"type": "function", "function": tool_call}]})
Calling the array object tool_call gets past this error, but I can't see any actual results being generated.
Also playing with messages.append({"role": "tool", "name": "multiply", "content": 0.0}) only returns 0.0.
This is what my final decoded tokenizer looks like:
<|begin_of_text|><|start_header_id|>system<|end_header_id|>

Environment: ipython
Cutting Knowledge Date: December 2023
Today Date: 26 Jul 2024

You are a helpful assistant with tool calling capabilities. When you receive a tool call response, use the content to format an answer to the orginal use question.<|eot_id|><|start_header_id|>user<|end_header_id|>

Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.

Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.Do not use variables.

{
"type": "function",
"function": {
"name": "multiply",
"description": "A function that multiplies two numbers",
"parameters": {
"type": "object",
"properties": {
"a": {
"type": "number",
"description": "The first number to multiply"
},
"b": {
"type": "number",
"description": "The second number to multiply"
}
},
"required": [
"a",
"b"
]
},
"return": {
"type": "number",
"description": "The result of multiplying the two specified numbers, as a float"
}
}
}

Hey, what's 5 multiplied by 2?<|eot_id|><|start_header_id|>assistant<|end_header_id|>

<|eot_id|><|start_header_id|>ipython<|end_header_id|>

0.0<|eot_id|><|start_header_id|>assistant<|end_header_id|>

{"name": "multiply", "parameters": {"a": "5", "b": "2"}}<|eot_id|>

Sign up or log in to comment