Skip to content

Setting chat_template using tuple raise reference before assignment on Ollama #637

@Erland366

Description

@Erland366

Hey, I am using custom chat template for all of my projects. Therefore I usually pass tuple to chat_template params on get_chat_template.

With latest commit, there's a conflict on this. In the get_chat_template, if you pass tuple, then it'll unpack 2 values from it (code that I was talking about). But it makes this ollama chat template error because we didn't define it in above. I can't pass 4 values into this because it'll raise an error for unpacking to much values.

I think the solution for now could be defining default value like this for now?

    if type(chat_template) in (list, tuple,):
        # list default value for unpacking
        default_values = ["", "", False, None]

        chat_template, stop_word, yes_map_eos_token, ollama_modelfile = (chat_template + default_values[len(chat_template):])[:4]
        chat_template, stop_word = chat_template
        assert(type(chat_template) is str)
        assert(type(stop_word) is str)

I think my explanation is horrible (sorry bad english), feel free to ask it more btw if you still confused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions