[NA] [Optimizer] Add support for multi-modal prompts in Opik Optimizer #3926
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.
Details
This PR adds comprehensive multimodal content support across the Opik Optimizer SDK, enabling optimization of prompts that include both text and images. The changes ensure that multimodal message structures are preserved throughout the optimization process.
Key Changes:
OptimizationResult Model: Updated to support multimodal content by changing
promptandinitial_promptfields fromlist[dict[str, str]]tolist[MessageDict], which properly supportscontentas either a string or a list of text/image parts.Hierarchical Reflective Optimizer:
PromptMessagemodel to useMessageDicttype for consistency with existing codebaseMeta Prompt Optimizer:
types.pyfile withPromptCandidate,CandidatePromptsResponse,ToolDescriptionCandidate, andToolDescriptionsResponsemodelsReporting Utilities:
display_optimized_prompt_diffto handle multimodal content in prompt diffs_content_to_stringhelper for converting multimodal content to string representation for diffing_format_message_contentutilityNew Dataset: Added
driving_hazard_50dataset for multimodal evaluation scenariosExample Script: Added
multimodal_example.pydemonstrating multimodal prompt optimizationChange checklist
Issues
Testing
test_optimization_result.pyto reflect new type definitionsDocumentation