Skip to content

Commit

Permalink
Merge pull request #19 from Blaizzy/pc/add-chat-ui
Browse files Browse the repository at this point in the history
fix llava template
  • Loading branch information
Blaizzy authored May 6, 2024
2 parents b4cac3b + f3e1e8d commit 8caa6bc
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions mlx_vlm/chat_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,22 @@ def chat(message, history, temperature, max_tokens):

if message["files"]:
chat.append(get_message_json(config["model_type"], message["text"]))

messages = processor.apply_chat_template(
chat,
tokenize=False,
add_generation_prompt=True,
)
else:
raise Exception("Please upload an image. Text only chat is not supported.")

if "chat_template" in processor.__dict__.keys():
messages = processor.apply_chat_template(
chat,
tokenize=False,
add_generation_prompt=True,
)

elif "tokenizer" in processor.__dict__.keys():
messages = processor.tokenizer.apply_chat_template(
chat,
tokenize=False,
add_generation_prompt=True,
)
response = ""
for chunk in generate(
model,
Expand Down

0 comments on commit 8caa6bc

Please sign in to comment.