mlx-vlm icon indicating copy to clipboard operation
mlx-vlm copied to clipboard

Support Chat API

Open madroidmaq opened this issue 1 year ago • 4 comments

Hope to support the API style for Chat (friendly to multi-turn conversations), currently it seems to be nearly supporting generate.

For example, in a similar way to the code example like Qwen/Qwen2-VL-2B-Instruct as follows:

messages = [
    {
        "role": "user",
        "content": [
            {
                "type": "image",
                "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
            },
            {"type": "text", "text": "Describe this image."},
        ],
    }
]

# apply messages
...

madroidmaq avatar Nov 13 '24 17:11 madroidmaq

You can do this manually.

I will later check if there is a great way to integrate this. The problem is that not all models support this format.

Blaizzy avatar Nov 13 '24 18:11 Blaizzy

Also we have a multi-turn example here:

https://github.com/Blaizzy/mlx-vlm/issues/68#issuecomment-2440233679

Blaizzy avatar Nov 13 '24 18:11 Blaizzy

Also we have a multi-turn example here:

#68 (comment)

Thanks, this example worked for me.

madroidmaq avatar Nov 14 '24 01:11 madroidmaq

My pleasure!

Blaizzy avatar Nov 14 '24 02:11 Blaizzy