Prompt Card

#3
by o0Linny0o - opened

Hey do you have a prompt template that we can use ?

Error rendering prompt with jinja template: "Error: Parser Error: Expected closing statement token.

This is usually an issue with the model's prompt template. If you are using a popular model, you can try to search the model under lmstudio-community, which will have fixed prompt templates. If you cannot find one, you are welcome to post this issue to our discord or issue tracker on GitHub. Alternatively, if you know how to write jinja templates, you can override the prompt template in My Models > model settings > Prompt Template.
this is what was in my model :
{%- if tools %}
{{- '<|im_start|>system\n' }}
{%- if messages[0].role == 'system' %}
{{- messages[0].content + '\n\n' }}
{%- endif %}
{{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{"name": , "arguments": }\n<|im_end|>\n" }}
{%- else %}
{%- if messages[0].role == 'system' %}
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
{%- for message in messages[::-1] %}
{%- set index = (messages|length - 1) - loop.index0 %}
{%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('') and message.content.endswith('')) %}
{%- set ns.multi_step_tool = false %}
{%- set ns.last_query_index = index %}
{%- endif %}
{%- endfor %}
{%- for message in messages %}
{%- if message.content is string %}
{%- set content = message.content %}
{%- else %}
{%- set content = '' %}
{%- endif %}
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{%- set reasoning_content = '' %}
{%- if message.reasoning_content is string %}
{%- set reasoning_content = message.reasoning_content %}
{%- else %}
{%- if '' in content %}
{%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %}
{%- set content = content.split('')[-1].lstrip('\n') %}
{%- endif %}
{%- endif %}
{%- if loop.index0 > ns.last_query_index %}
{%- if loop.last or (not loop.last and reasoning_content) %}
{{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }}
{%- else %}
{{- '<|im_start|>' + message.role + '\n' + content }}
{%- endif %}
{%- else %}
{{- '<|im_start|>' + message.role + '\n' + content }}
{%- endif %}
{%- if message.tool_calls %}
{%- for tool_call in message.tool_calls %}
{%- if (loop.first and content) or (not loop.first) %}
{{- '\n' }}
{%- endif %}
{%- if tool_call.function %}
{%- set tool_call = tool_call.function %}
{%- endif %}
{{- '\n{"name": "' }}
{{- tool_call.name }}
{{- '", "arguments": ' }}
{%- if tool_call.arguments is string %}
{{- tool_call.arguments }}
{%- else %}
{{- tool_call.arguments | tojson }}
{%- endif %}
{{- '}\n' }}
{%- endfor %}
{%- endif %}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
{{- '<|im_start|>user' }}
{%- endif %}
{{- '\n\n' }}
{{- content }}
{{- '\n' }}
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- if enable_thinking is defined and enable_thinking is false %}
{{- '\n\n\n\n' }}
{%- endif %}
{%- endif %}

You should be using Qwen3 settings, so ChatML format. Not sure why you're getting an error, I've had no issue with kcpp.

using LMStudio? try this prompt:

{# ─── 0. GUARD INPUTS ─────────────────────────────────────────────── #}
{%- set msgs = [] -%}
{%- if messages is defined and messages is not none and messages|length > 0 -%}
{%- set first_msg = messages[0] -%}
{%- if first_msg.role is defined -%}
{%- set msgs = messages -%}
{%- endif -%}
{%- endif -%}

{%- set tlist = [] -%}
{%- if tools is defined and tools is not none and tools|length > 0 -%}
{%- set first_tool = tools[0] -%}
{%- if first_tool.name is defined -%}
{%- set tlist = tools -%}
{%- endif -%}
{%- endif -%}

{# ─── 1. SYSTEM + TOOLS HEADER ─────────────────────────────────────── #}
{%- if tlist|length > 0 -%}
<|im_start|>system
{%- if msgs|length > 0 and msgs[0].role == 'system' -%}
{{ msgs[0].content | trim }}
{%- endif %}

Tools

You may call these functions by emitting a … block.

{%- for tool in tlist -%} {{ tool | tojson }} {%- endfor -%}

<|im_end|>
{%- else -%}
{%- if msgs|length > 0 and msgs[0].role == 'system' -%}
<|im_start|>system
{{ msgs[0].content | trim }}
<|im_end|>
{%- endif -%}
{%- endif %}

{# ─── 2. CONVERSATION LOOP ────────────────────────────────────────── #}
{%- for m in msgs -%}
{%- set role = m.role -%}
{%- set txt = (m.content if m.content is defined else '') | trim -%}

{# -- user or non-first system messages -- #}
{%- if role == 'user' or (role == 'system' and loop.index0 > 0) -%}
<|im_start|>{{ role }}
{{ txt }}
<|im_end|>

{# -- assistant messages -- #}
{%- elif role == 'assistant' -%}
<|im_start|>assistant
{{ txt }}
<|im_end|>

{# emit any tool calls #}
{%- if m.tool_calls is defined and m.tool_calls|length > 0 -%}
  {%- for call in m.tool_calls -%}
    {%- set fn = call.function if call.function is defined else call -%}
{"name":"{{ fn.name }}","arguments":{{ fn.arguments | tojson }}} {%- endfor -%} {%- endif %}

{# -- tool responses (render back as user) -- #}
{%- elif role == 'tool' -%}
<|im_start|>user

{{ txt }}

<|im_end|>
{%- endif -%}
{%- endfor -%}

{# ─── 3. OPTIONAL CONTINUATION PROMPT ─────────────────────────────── #}
{%- if add_generation_prompt -%}
<|im_start|>assistant
{%- endif %}

Sign up or log in to comment