API: Relax multimodal format, fixes HuggingFace Chat UI (#6353)

This commit is contained in:
Stefan Merettig 2024-09-03 04:03:15 +02:00 committed by GitHub
parent 4c74c7a116
commit 9a150c3368
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -154,8 +154,9 @@ def convert_history(history):
elif item['type'] == 'text' and isinstance(item['text'], str): elif item['type'] == 'text' and isinstance(item['text'], str):
content = item['text'] content = item['text']
if image_url and content: if image_url:
new_history.append({"image_url": image_url, "role": "user"}) new_history.append({"image_url": image_url, "role": "user"})
if content:
new_history.append({"content": content, "role": "user"}) new_history.append({"content": content, "role": "user"})
else: else:
new_history.append(entry) new_history.append(entry)