[Refactor] Refactor the Generate Interface #140
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After refactoring, all VLMs (no matter API ones or OpenSource ones), will follow the following input format:
A list of dictionary: A multi-modal message is represented by a list of dictionary, each dictionary has two keys:
type
andvalue
:type
: We currently support two types, choices are["image", "text"]
.value
: Whentype=='text'
, the value is the text message (a single string); whentype=='image'
, the value can be the local path of an image file, or the image URL.Example:
For convenience sake, we also support to take a list of string as inputs. In that case, we will check if a string is an image path or image URL and automatically convert it to the list[dict] format.
Example:
Though the input format accepts multiple images in a multi-modal message, sometimes the VLM does not support that feature (for example, some VLMs only accept a single image). In such case, only the first image will be processed by the VLM, and there will be a warning message.
Another advantage of the new format is, it can be compatible with potential future updates. For examples, in the future, new types can be added to be compatible with audio or signals from custom sensors.