Skip to content

Commit

Permalink
Convert messages with content blocks to plain text messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts committed Jun 24, 2024
1 parent 242753e commit e8905d1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions forge/forge/llm/providers/llamafile/llamafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ def _get_chat_completion_args(
# seed should be set from config
completion_kwargs["seed"] = 0

# Convert all messages with content blocks to simple text messages
for message in messages:
if isinstance(content := message.get("content"), list):
message["content"] = "\n\n".join(
b["text"]
for b in content
if b["type"] == "text"
# FIXME: add support for images through image_data completion kwarg
)

return messages, completion_kwargs, parse_kwargs

def _adapt_chat_messages_for_mistral_instruct(
Expand Down

0 comments on commit e8905d1

Please sign in to comment.