-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ChatMessage content being str
-only doesn't allow user to pass image
#7848
Comments
str
but to pass image we need it to be list similar to how OpenAI allows itstr
-only doesn't allow user to pass image
str
-only doesn't allow user to pass imagestr
-only doesn't allow user to pass image
I will try to add this functionality :) |
I've reviewed the base code and propose that we enable the 'content' of a 'ChatMessage' to be set as a list containing 'str', 'Path', or any type used to encode an image. This will require us to rewrite the 'to_openai_format' method and incorporate image processing with 'base64' for calls involving images. We'll also need to address serialization issues, but we can handle those once #7849 is merged into the main branch to avoid merge conflicts. The main challenge will be accurately distinguishing between images and text in the input list, especially when the input is a string. It would be helpful to know which data types you want to support for images. I'll begin working on this after the mentioned PR is merged. |
I don't think we should try and extract this info ourselves. We should make the user specify. My idea is to make a ContentPart class with type, text, image_url, base_64, and detail. We can then have helper methods in this class that helps with formatting. Essentially, we would allow for something like this:
We should also look into deprecating Functions and supporting Tools within ChatMessage as that has also changed. |
I will implement this functionality. Regarding the deprecation of Functions, we could open an issue to handle it separately. |
I agree with this direction. We need to look at all the multimodal message formats across all LLM providers and deduce common denominators. From a brief cursory look I believe these multimodal/multipart messages are all json payloads of various formats (schemas). So let's come up with a nice abstractions (like the ContentPart idea above) that abstracts the implementation details and see how they map to data structures across various LLM providers. |
We can keep it much simpler. As of now models can receive and generate the following:
We have all the necessary abstractions to define the above. Given that we say that This abstracts at an high level all the supported type of data a model receives and generates. If model X needs their input or generates their output in a certain format its Generator will handle the conversion, but that's an implementation detail. Introducing new classes or new abstractions is not the way to go in my opinion. |
@silvanocerza I like the simplicity of your solution, but I've just read the code for 'ByteStream' and we should expect the metadata to be populated with some flag to indicate the content type, else we won't be able to distinguish. That's why I believe that the 'ContentPart' approach to be easier to handle and allows us to provide for brother input types for the different formats. |
Still relevant, reopening. |
I agree - schedule it soon as well. |
Trying to understand how this implementation would work. Let's say that the Then does that mean we would need to handle the conversion in, say
This works provided that the user specifies the valid
With this implementation, the abstractions aren't modified as much and the conversions would (probably) occur in some helper functions for each generator. This would allow for usage like so:
Is this what you had in mind or is there some other insight you could provide to help with an implementation? |
Just wondering if this is any further along or if there are any new workarounds to feed images in to a chat generator? |
Yes please make this higher priority! This is a huge piece of functionality from Chat GPT |
Ollama just released vision support. If we stick to the bytestream implementation I suggested, we can add support to it in the Ollama implementation by doing something like
Which would once again look the same as the OpenAI implementation when the user calls it.
|
Hi @silvanocerza , do you mind sharing more about the broader vision for |
I am planning to add multimodal support in haystack-experimental (it already has some advanced tool supports there). I am opening an issue for this (basically my to-do list for better visibility since I am aware that some people are asking multimodality): deepset-ai/haystack-experimental#135 |
Is your feature request related to a problem? Please describe.
While talking to our bot, the user is allowed to send an image. This image is sent to vision enabled LLM bot. Haystack ChatMessage class
content
only allows string but it needs to allow a List to be passed. Here's the OpenAI page the Haystack refers to forcontent
which allows array andimage_url
that can be sent that way.Describe the solution you'd like
ChatMessage to be able to handle inbound image
Describe alternatives you've considered
Not using generator component at all is the only other alternative I can explore.
Additional context
Haystack's ChatMessage
content
: LinkOpenAI's chat message parameter: Link
How ChatMessage content is getting populated from the generator: Link
The text was updated successfully, but these errors were encountered: