mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2025-01-13 12:10:18 +00:00
tool-call
: Qwen 2.5 Instruct also requires object arguments
This commit is contained in:
parent
b10ef04d8d
commit
bc3e0c0830
@ -36,7 +36,7 @@ llama_chat_template::llama_chat_template(const std::string & chat_template, cons
|
|||||||
_supports_tools = chat_template.find("tools") != std::string::npos;
|
_supports_tools = chat_template.find("tools") != std::string::npos;
|
||||||
_requires_object_arguments =
|
_requires_object_arguments =
|
||||||
chat_template.find("tool_call.arguments | items") != std::string::npos
|
chat_template.find("tool_call.arguments | items") != std::string::npos
|
||||||
|| chat_template.find("{{- tool_call.arguments | tojson }}") != std::string::npos;
|
|| chat_template.find("tool_call.arguments | tojson") != std::string::npos;
|
||||||
_supports_system_role = chat_template.find("System role not supported") == std::string::npos;
|
_supports_system_role = chat_template.find("System role not supported") == std::string::npos;
|
||||||
|
|
||||||
if (chat_template.find("<tool_call>") != std::string::npos) {
|
if (chat_template.find("<tool_call>") != std::string::npos) {
|
||||||
|
@ -21,7 +21,7 @@ For each function call, return a json object with function name and arguments wi
|
|||||||
Print a hello world message with python.<|im_end|>
|
Print a hello world message with python.<|im_end|>
|
||||||
<|im_start|>assistant
|
<|im_start|>assistant
|
||||||
<tool_call>
|
<tool_call>
|
||||||
{"name": "ipython", "arguments": "{\"code\": \"print('Hello, World!')\"}"}
|
{"name": "ipython", "arguments": {"code": "print('Hello, World!')"}}
|
||||||
</tool_call><|im_end|>
|
</tool_call><|im_end|>
|
||||||
<|im_start|>user
|
<|im_start|>user
|
||||||
<tool_response>
|
<tool_response>
|
||||||
@ -33,7 +33,7 @@ Anything else?<|im_end|>
|
|||||||
Test a tautology.<|im_end|>
|
Test a tautology.<|im_end|>
|
||||||
<|im_start|>assistant
|
<|im_start|>assistant
|
||||||
<tool_call>
|
<tool_call>
|
||||||
{"name": "test", "arguments": "{\"condition\":true}"}
|
{"name": "test", "arguments": {"condition": true}}
|
||||||
</tool_call><|im_end|>
|
</tool_call><|im_end|>
|
||||||
<|im_start|>user
|
<|im_start|>user
|
||||||
<tool_response>
|
<tool_response>
|
||||||
@ -45,7 +45,7 @@ Truth is definitely true.<|im_end|>
|
|||||||
Check it on the web.<|im_end|>
|
Check it on the web.<|im_end|>
|
||||||
<|im_start|>assistant
|
<|im_start|>assistant
|
||||||
<tool_call>
|
<tool_call>
|
||||||
{"name": "brave_search", "arguments": "{\"query\": \"what is truth anyway am I right?\"}"}
|
{"name": "brave_search", "arguments": {"query": "what is truth anyway am I right?"}}
|
||||||
</tool_call><|im_end|>
|
</tool_call><|im_end|>
|
||||||
<|im_start|>user
|
<|im_start|>user
|
||||||
<tool_response>
|
<tool_response>
|
||||||
|
@ -21,7 +21,7 @@ For each function call, return a json object with function name and arguments wi
|
|||||||
Print a hello world message with python.<|im_end|>
|
Print a hello world message with python.<|im_end|>
|
||||||
<|im_start|>assistant
|
<|im_start|>assistant
|
||||||
<tool_call>
|
<tool_call>
|
||||||
{"name": "ipython", "arguments": "{\"code\": \"print('Hello, World!')\"}"}
|
{"name": "ipython", "arguments": {"code": "print('Hello, World!')"}}
|
||||||
</tool_call><|im_end|>
|
</tool_call><|im_end|>
|
||||||
<|im_start|>user
|
<|im_start|>user
|
||||||
<tool_response>
|
<tool_response>
|
||||||
@ -33,7 +33,7 @@ Anything else?<|im_end|>
|
|||||||
Test a tautology.<|im_end|>
|
Test a tautology.<|im_end|>
|
||||||
<|im_start|>assistant
|
<|im_start|>assistant
|
||||||
<tool_call>
|
<tool_call>
|
||||||
{"name": "test", "arguments": "{\"condition\":true}"}
|
{"name": "test", "arguments": {"condition": true}}
|
||||||
</tool_call><|im_end|>
|
</tool_call><|im_end|>
|
||||||
<|im_start|>user
|
<|im_start|>user
|
||||||
<tool_response>
|
<tool_response>
|
||||||
@ -45,7 +45,7 @@ Truth is definitely true.<|im_end|>
|
|||||||
Check it on the web.<|im_end|>
|
Check it on the web.<|im_end|>
|
||||||
<|im_start|>assistant
|
<|im_start|>assistant
|
||||||
<tool_call>
|
<tool_call>
|
||||||
{"name": "brave_search", "arguments": "{\"query\": \"what is truth anyway am I right?\"}"}
|
{"name": "brave_search", "arguments": {"query": "what is truth anyway am I right?"}}
|
||||||
</tool_call><|im_end|>
|
</tool_call><|im_end|>
|
||||||
<|im_start|>user
|
<|im_start|>user
|
||||||
<tool_response>
|
<tool_response>
|
||||||
|
@ -92,7 +92,7 @@ Respond in the format {"name": function name, "parameters": dictionary of argume
|
|||||||
|
|
||||||
Print a hello world message with python.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
Print a hello world message with python.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
{"name": "ipython", "parameters": "{\"code\": \"print('Hello, World!')\"}"}<|eot_id|><|start_header_id|>ipython<|end_header_id|>
|
{"name": "ipython", "parameters": {"code": "print('Hello, World!')"}}<|eot_id|><|start_header_id|>ipython<|end_header_id|>
|
||||||
|
|
||||||
"{\"stdout\": \"Hello, World!\"}"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
"{\"stdout\": \"Hello, World!\"}"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ Anything else?<|eot_id|><|start_header_id|>user<|end_header_id|>
|
|||||||
|
|
||||||
Test a tautology.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
Test a tautology.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
{"name": "test", "parameters": "{\"condition\":true}"}<|eot_id|><|start_header_id|>ipython<|end_header_id|>
|
{"name": "test", "parameters": {"condition": true}}<|eot_id|><|start_header_id|>ipython<|end_header_id|>
|
||||||
|
|
||||||
"true"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
"true"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ Truth is definitely true.<|eot_id|><|start_header_id|>user<|end_header_id|>
|
|||||||
|
|
||||||
Check it on the web.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
Check it on the web.<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
{"name": "brave_search", "parameters": "{\"query\": \"what is truth anyway am I right?\"}"}<|eot_id|><|start_header_id|>ipython<|end_header_id|>
|
{"name": "brave_search", "parameters": {"query": "what is truth anyway am I right?"}}<|eot_id|><|start_header_id|>ipython<|end_header_id|>
|
||||||
|
|
||||||
"{\"title\":\"Truth: don't ask the web, ask an LLM instead!\",\"url\":\"https://en.wikipedia.org/wiki/Truth\"}"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
"{\"title\":\"Truth: don't ask the web, ask an LLM instead!\",\"url\":\"https://en.wikipedia.org/wiki/Truth\"}"<|eot_id|><|start_header_id|>assistant<|end_header_id|>
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ def handle_chat_template(model_id, variant, template_src):
|
|||||||
render_context = json.loads(json.dumps(context))
|
render_context = json.loads(json.dumps(context))
|
||||||
|
|
||||||
# Work around Llama-3.1 template quirk: it expects tool_call.function.arguments to be an object rather than its JSON string representation.
|
# Work around Llama-3.1 template quirk: it expects tool_call.function.arguments to be an object rather than its JSON string representation.
|
||||||
if 'tool_call.arguments | items' in template_src:
|
if 'tool_call.arguments | items' in template_src or 'tool_call.arguments | tojson' in template_src:
|
||||||
for message in render_context['messages']:
|
for message in render_context['messages']:
|
||||||
if 'tool_calls' in message:
|
if 'tool_calls' in message:
|
||||||
for tool_call in message['tool_calls']:
|
for tool_call in message['tool_calls']:
|
||||||
|
Loading…
Reference in New Issue
Block a user