input:"I should check the weather...</think>\n<tool_call>\n<function=get_weather>\n<parameter=city>\nParis\n</parameter>\n</function>\n</tool_call>",
thinkValue:&api.ThinkValue{Value:true},
expectedThinking:"I should check the weather...",
expectedCalls:[]api.ToolCall{
{
Function:api.ToolCallFunction{
Name:"get_weather",
Arguments:map[string]any{"city":"Paris"},
},
},
},
},
{
name:"thinking content then tool call",
input:"Let me think...</think>\nI'll check for you.\n<tool_call>\n<function=search>\n<parameter=query>\ntest\n</parameter>\n</function>\n</tool_call>",
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>")
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+
"</IMPORTANT><|im_end|>\n"+
"<|im_start|>user\nWhat's the weather in Paris?<|im_end|>\n"+
"<|im_start|>assistant\n<think>\n",
},
{
name:"tool call with response",
msgs:[]api.Message{
{Role:"user",Content:"What's the weather in Paris?"},
{
Role:"assistant",
ToolCalls:[]api.ToolCall{
{
Function:api.ToolCallFunction{
Name:"get_weather",
Arguments:map[string]any{"city":"Paris"},
},
},
},
},
{Role:"tool",Content:"Sunny, 72F"},
},
tools:[]api.Tool{
{
Type:"function",
Function:api.ToolFunction{
Name:"get_weather",
Description:"Get the current weather",
Parameters:api.ToolFunctionParameters{
Type:"object",
Required:[]string{"city"},
Properties:map[string]api.ToolProperty{
"city":{Type:api.PropertyType{"string"},Description:"The city name"},
},
},
},
},
},
isThinking:true,
thinkValue:&api.ThinkValue{Value:true},
expected:"<|im_start|>system\n"+
"# Tools\n\nYou have access to the following functions:\n\n<tools>\n"+
"<function>\n<name>get_weather</name>\n"+
"<description>Get the current weather</description>\n"+
"<parameters>\n"+
"<parameter>\n<name>city</name>\n<type>string</type>\n<description>The city name</description>\n</parameter>\n"+
"<required>[\"city\"]</required>\n"+
"</parameters>\n</function>\n</tools>\n\n"+
"If you choose to call a function ONLY reply in the following format with NO suffix:\n\n"+
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+
"</IMPORTANT><|im_end|>\n"+
"<|im_start|>user\nWhat's the weather in Paris?<|im_end|>\n"+
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+
"</IMPORTANT><|im_end|>\n"+
"<|im_start|>user\nWhat's the weather?<|im_end|>\n"+
"<|im_start|>assistant\n<think></think>Let me check that for you.\n"+
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+
"</IMPORTANT><|im_end|>\n"+
"<|im_start|>user\nWeather in Paris and London?<|im_end|>\n"+
name:"thinking disabled even when model supports it",
msgs:[]api.Message{
{Role:"user",Content:"Hello!"},
},
isThinking:true,// model supports thinking
thinkValue:nil,// but user didn't request it
expected:"<|im_start|>system\n<|im_end|>\n"+
"<|im_start|>user\nHello!<|im_end|>\n"+
"<|im_start|>assistant\n<think></think>",
},
{
name:"complex message history with thinking, tools, tool calls, tool results and content",
msgs:[]api.Message{
{Role:"user",Content:"What's the weather in Paris and London? Also, what's 2+2?"},
{Role:"assistant",Content:"",Thinking:"I need to check the weather for both cities and calculate 2+2. Let me start with the weather calls.",ToolCalls:[]api.ToolCall{
{Role:"assistant",Content:"Based on the weather data, Paris is sunny at 22°C and London is rainy at 15°C. Also, 2+2 equals 4.",Thinking:"Perfect! I have all the information needed to provide a complete answer."},
},
tools:[]api.Tool{
{
Type:"function",
Function:api.ToolFunction{
Name:"get_weather",
Parameters:api.ToolFunctionParameters{
Type:"object",
Properties:map[string]api.ToolProperty{
"city":{Type:api.PropertyType{"string"}},
},
},
},
},
{
Type:"function",
Function:api.ToolFunction{
Name:"calculate",
Parameters:api.ToolFunctionParameters{
Type:"object",
Properties:map[string]api.ToolProperty{
"expression":{Type:api.PropertyType{"string"}},
},
},
},
},
},
isThinking:true,
thinkValue:&api.ThinkValue{Value:true},
expected:"<|im_start|>system\n"+
"# Tools\n\nYou have access to the following functions:\n\n<tools>\n"+
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+
"</IMPORTANT><|im_end|>\n"+
"<|im_start|>user\nWhat's the weather in Paris and London? Also, what's 2+2?<|im_end|>\n"+
"<|im_start|>assistant\n"+
"<think>\nI need to check the weather for both cities and calculate 2+2. Let me start with the weather calls.\n</think>\n"+
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+
"- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n"+
"- Required parameters MUST be specified\n"+
"- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n"+
"- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n"+