Add image generation model and update provider to support it#30
Conversation
…l below OllamaImageGenerationModel
|
@milindmore22 Thanks for the PR. We use |
dkotter
left a comment
There was a problem hiding this comment.
Few minor comments but otherwise this looks good to me and tests well!
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #30 +/- ##
==========================================
Coverage ? 61.68%
Complexity ? 100
==========================================
Files ? 7
Lines ? 462
Branches ? 0
==========================================
Hits ? 285
Misses ? 177
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dkotter
left a comment
There was a problem hiding this comment.
Would also be great to get unit tests added to cover these new changes
TylerB24890
left a comment
There was a problem hiding this comment.
All looks good to me!
Is there ever a case where the model would have the image capability but not be an image generation model? If not, I would propose updating the name of the isLikelyImageGenerationModel() method to isImageGenerationModel() -- less misleading and it matches the variable name it's being applied to
|
Renamed [Update] |
Yeah, I'm getting the same error now. Going to hold on merging this until they get that resolved (hopefully soon) |
|
According to ollama/ollama#15433 the related PR ollama/ollama#15443 was in the v0.20.5 release so perhaps a local Ollama update will see this working again? |
Yeah, I pulled the latest version (0.27.0) and still seeing the same issue. Reading through that thread, sounds like most people are still having the same problem (and would be ideal if the issue was opened back up). There is a "fix" detailed on the thread for those running it through Homebrew but I have it installed as a normal package so wasn't able to test that. |
|
The issue has been resolved in the latest Ollama version 0.21.0, as reported in the pull request ollama/ollama#15588. |
Description of the Change
This PR adds support for Image generation model based on experimental feature of ollama please refer blog
This pull request adds support for image generation models to the Ollama provider integration. The most significant changes include the introduction of a new
OllamaImageGenerationModelclass, updates to model metadata detection to identify image generation capabilities, and enhancements to provider logic to instantiate the correct model type based on capabilities.Image Generation Model Support:
OllamaImageGenerationModelclass that implements image generation using the Ollama/api/generateendpoint, including prompt extraction, response parsing, and custom timeout handling.OllamaProviderto instantiateOllamaImageGenerationModelwhen a model supports image generation, based on its capabilities. [1] [2]Model Metadata Detection:
OllamaModelMetadataDirectoryto detect image generation models by checking for the'image'capability, and to construct appropriateModelMetadatafor such models with relevant options and output types. [1] [2] [3] [4]Tooling and Static Analysis:
phpstan.neon.distto temporarily ignore the newOllamaImageGenerationModel.phpfile for static analysis, consistent with other files depending on unreleased WordPress core AI Client classes.Warning
Supported only on MacOS (because experiments are only avilable on MacOS) Tested with x/flux2-klein and x/z-image-turbo
Screenshots
Closes #
How to test the Change
Download Model
Test Model
ollama run x/flux2-klein "a cat holding a sign that says hello world"Test Curl
Now you can try generate Image in WordPress
Changelog Entry
Added - support Image generation model
Credits
Props @milindmore22
Checklist: