You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR enhances the Florence2Model.caption() method to accept an optional detail parameter, allowing callers to override the caption detail level (brief/normal/detailed) at call time rather than only at initialization. It also adds a CaptionDetail.from_str() classmethod for convenient string-to-enum resolution.
Added CaptionDetail.from_str() classmethod with aliases ("brief", "normal", "detailed", "more_detailed") for resolving detail-level strings to enum members
Extended Florence2Model.caption() signature with an optional detail: str | CaptionDetail | None parameter that falls back to the instance default when None
The caption_batch() method was not updated with the same detail parameter, creating an API inconsistency between single and batch captioning
Confidence Score: 4/5
This PR is safe to merge with low risk — it adds an optional parameter with a sensible default, preserving backward compatibility.
The change is small, backward-compatible, and well-structured. The only concern is the API inconsistency between caption() (supports detail override) and caption_batch() (does not), and a minor gap where from_str can raise an unhelpful KeyError on invalid input.
No files require special attention; dimos/models/vl/florence.py is the only changed file and the changes are straightforward.
Important Files Changed
Filename
Overview
dimos/models/vl/florence.py
Adds CaptionDetail.from_str() classmethod and extends caption() with optional detail parameter; caption_batch() not updated with same override capability.
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["caption(image, detail=None)"] --> B{detail is None?}
B -- Yes --> C["Use self._task_prompt\n(instance default)"]
B -- No --> D{isinstance CaptionDetail?}
D -- Yes --> E["Use detail.value"]
D -- No --> F["CaptionDetail.from_str(detail)"]
F --> G{In _ALIASES?}
G -- Yes --> H["Return alias match"]
G -- No --> I["cls[name.upper()]\n(KeyError if invalid)"]
H --> E
I --> E
C --> J["Process image with task_prompt"]
E --> J
J --> K["Generate caption"]
caption() now accepts an optional detail parameter, but caption_batch() still hardcodes self._task_prompt. This creates an API inconsistency — users who discover they can override detail level on single captions will expect the same on batches. Consider adding the same detail: str | CaptionDetail | None = None parameter here as well, with the same resolution logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Problem
Closes DIM-XXX
Solution
Breaking Changes
How to Test
Contributor License Agreement