Skip to content

fix(workers-ai): pass source image and mask to executeQuery in the correct order - #6373

Open
Lubaoshuai wants to merge 2 commits into
langchain4j:mainfrom
Lubaoshuai:6149-fix-image-mask-swap
Open

Lubaoshuai wants to merge 2 commits into
langchain4j:mainfrom
Lubaoshuai:6149-fix-image-mask-swap

Conversation

@Lubaoshuai

Copy link
Copy Markdown
Contributor

Issue

Fixes #6149

Change

WorkersAiImageModel builds its request through executeQuery(String prompt, Image image, Image mask), but both edit() overloads passed the arguments in the opposite order:

  • edit(image, prompt) called executeQuery(prompt, null, image) — the source pixels were sent in the mask field and image was null, so the image to edit was never sent as the image.
  • edit(image, mask, prompt) called executeQuery(prompt, mask, image) — the two fields were exchanged.

Both overloads now call executeQuery(prompt, image, mask) as declared. The generate() overloads are unaffected (they pass null, null).

Test

Added WorkersAiImageModelTest using MockHttpClient (requires the langchain4j-http-client test-jar in the module):

  • edit(image, prompt) serializes the source pixels under "image" and leaves "mask" null
  • edit(image, mask, prompt) serializes the source and mask pixels under the correct, distinct fields
  • generate(prompt) leaves both null (regression)

mvn -pl langchain4j-workers-ai test: 77 tests, 0 failures.

…rrect order

The edit(Image, String) overload sent the source image in the mask field
(and image as null), and edit(Image, Image, String) swapped the two.
Both now map to executeQuery(prompt, image, mask) as declared.

Adds WorkersAiImageModelTest with a mocked HTTP client covering edit,
edit-with-mask and generate request payloads.

Fixes langchain4j#6149

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] WorkersAiImageModel.edit() sends the source image in the "mask" field

1 participant