Class WorkersAiImageModel
java.lang.Object
dev.langchain4j.model.workersai.client.AbstractWorkersAIModel
dev.langchain4j.model.workersai.WorkersAiImageModel
- All Implemented Interfaces:
ImageModel
WorkerAI Image model.
To edit an image, give its content as base64 data, for example
Image.builder().base64Data(base64Data).mimeType("image/png").build(). The image and the mask are sent to
Workers AI as the bytes of their files. Images given by URL are not supported.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class AbstractWorkersAIModel
accountId, client, modelName -
Constructor Summary
ConstructorsConstructorDescriptionConstructor with Builder.WorkersAiImageModel(String accountId, String modelName, String apiToken) Constructor with Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic WorkersAiImageModel.Builderbuilder()Builder access.convertAsImage(byte[] data) Convert Workers AI Image Generation output to LangChain4j model.Given an existing image, edit this image following the given prompt and apply the changes only to the part of the image specified by the given mask.Given an existing image, edit this image following the given prompt.Given a prompt, generate an image.Generate image and save to file.int[]Convert an image into a array of number, supposedly the Pixels.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ImageModel
generate
-
Constructor Details
-
WorkersAiImageModel
Constructor with Builder.- Parameters:
builder- builder.
-
WorkersAiImageModel
-
-
Method Details
-
builder
-
generate
Given a prompt, generate an image.- Specified by:
generatein interfaceImageModel- Parameters:
prompt- The prompt to generate an image from.- Returns:
- The generated image Response.
-
edit
-
edit
Given an existing image, edit this image following the given prompt and apply the changes only to the part of the image specified by the given mask.- Specified by:
editin interfaceImageModel- Parameters:
image- The image to be edited.mask- The image mask to apply to delimit the area to edit.prompt- The prompt to edit the image.- Returns:
- The generated image Response.
-
generate
-
getPixels
Convert an image into a array of number, supposedly the Pixels.This method reads the image from the given URL, including local
file:URLs. Use it only with URLs that you control, never with URLs that come from end users or models.- Parameters:
imageUrl- current image URL- Returns:
- pixels of the image
- Throws:
Exception- return an exception if pixel not returned
-
convertAsImage
Convert Workers AI Image Generation output to LangChain4j model.- Parameters:
data- output image- Returns:
- output image converted
-