Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to parse chat template: 11:16: error: Expected expression, got: '(' {%- if (not loop.first) or (system_message is not none) %} ---^-- #3382

Open
HalloWelt42 opened this issue Jan 12, 2025 · 0 comments
Labels
bindings gpt4all-binding issues bug-unconfirmed

Comments

@HalloWelt42
Copy link

Error: Failed to parse chat template: 11:16: error: Expected expression, got: '(' {%- if (not loop.first) or (system_message is not none) %} ---^-------

system: Apple M1 Max 32 GB
vesion: v3.6.1
Model: EM German Mistral


{%- set system_message = false %}
{%- if messages[0]['role'] == 'system' %}
    {%- set loop_start = 1 %}
    {%- set system_message = true %}
    {{- messages[0]['content'] }}
{%- else %}
    {%- set loop_start = 0 %}
{%- endif %}
{%- for message in messages %}
    {%- if loop.index0 >= loop_start %}
        {%- if (not loop.first) or (system_message is not none)  %}
            {{- ' ' }}
        {%- endif %}
        {%- if message['role'] == 'user' %}
            {{- 'USER: ' + message['content'] }}
        {%- elif message['role'] == 'assistant' %}
            {{- 'ASSISTANT: ' + message['content'] }}
        {%- else %}
            {{- raise_exception('After the optional system message, conversation roles must be either user or assistant.') }}
        {%- endif %}
    {%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
    {%- if messages %}
        {{- ' ' }}
    {%- endif %}
    {{- 'ASSISTANT:' }}
{%- endif %}
@HalloWelt42 HalloWelt42 added bindings gpt4all-binding issues bug-unconfirmed labels Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindings gpt4all-binding issues bug-unconfirmed
Projects
None yet
Development

No branches or pull requests

1 participant