Skip to content

Conversation

@ochafik
Copy link
Contributor

@ochafik ochafik commented Aug 7, 2025

Problems in that template came from the detection of whether content needs to be non-null, which needs to add more messages when the logic only triggers in some loop iterations.

  {%- for message in messages %}
    {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
        {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
    {%- elif message.role == "assistant" and not message.tool_calls %}
        {%- set content = message.content %}
        {%- if not loop.last %}
            {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
        {%- endif %}
        {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
    {%- elif message.role == "assistant" %}
        {%- set content = message.content %}
        {%- if not loop.last %}
            {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
        {%- endif %}
        {{- '<|im_start|>' + message.role }}

@ochafik ochafik merged commit bc6cec9 into main Aug 7, 2025
1 check passed
@ochafik ochafik deleted the fix-qwq branch August 7, 2025 22:39
ochafik added a commit to ochafik/minja that referenced this pull request Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant