Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion llama_cpp/llama_chat_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -5371,14 +5371,19 @@ class Qwen35ChatHandler(MTMDChatHandler):
"{%- if not messages -%}"
" {{- raise_exception('No messages provided.') -}}"
"{%- endif -%}"
"{%- if tools and tools is iterable and tools is not mapping -%}"
"{%- if tools and tools is iterable and tools is not mapping and tool_choice != 'none' -%}"
" {{- '<|im_start|>system\n' -}}"
" {{- '# Tools\n\nYou have access to the following functions:\n\n<tools>' -}}"
" {%- for tool in tools -%}"
" {{- '\n' -}}"
" {{- tool | tojson -}}"
" {%- endfor -%}"
" {{- '\n</tools>' -}}"
" {%- if tool_choice == 'required' -%}"
" {{- '\n\nYou MUST call at least one function in your response. Answering without a function call is not allowed. Select the most appropriate tool based on the user request and its description.\n' -}}"
" {%- else -%}"
" {{- '\n\nYou have access to tools. Use them only when necessary.\nFollow the description of each tool to determine if and when to call it.\nIf no tool is needed, respond directly.\n' -}}"
" {%- endif -%}"
" {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\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>' -}}"
" {%- if messages[0].role == 'system' -%}"
" {%- set content = render_content(messages[0].content, false, true) | trim -%}"
Expand Down