Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flag to specify if messages are multimodal #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

comhar
Copy link

@comhar comhar commented Sep 18, 2024

This PR adds an option to specify if your messages are multimodal. This is useful because some text-only models like DeepSeek expect messages with the following format:

{"role": "user", "content": "some message"}

Currently cosette only generates messages with the format below which throws an error when calling the DeepSeek API. This isn't unique to DeepSeek. The same error occurs with models hosted by other providers like Groq.

{"role": "user", "content": [{"type": "text", "text": "some message"}]}

@comhar comhar requested a review from jph00 September 18, 2024 21:01
**kwargs):
"Helper to create a `dict` appropriate for a message. `kwargs` are added as key/value pairs to the message"
if hasattr(content, 'content'): content,role = content.content,content.role
if isinstance(content, ChatCompletion): return find_block(content)
if content is not None and not isinstance(content, list): content=[content]
content = [_mk_content(o) for o in content] if content else ''
if content and not multimodal: content = " .".join(content)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a reasonable way to join the list? I guess "\n" would be another option.

@jph00
Copy link
Contributor

jph00 commented Sep 19, 2024

This looks like pretty much the same format as claudette. Could you see if you can pull some of that functionality out into some shared utilities or base class or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants