Package dev.langchain4j.model.workersai
Class WorkersAiImageModel
java.lang.Object
dev.langchain4j.model.workersai.client.AbstractWorkersAIModel
dev.langchain4j.model.workersai.WorkersAiImageModel
- All Implemented Interfaces:
ImageModel
WorkerAI Image model.
-
Nested Class Summary
-
Field Summary
Fields inherited from class dev.langchain4j.model.workersai.client.AbstractWorkersAIModel
accountId, modelName, workerAiClient
-
Constructor Summary
ConstructorDescriptionConstructor with Builder.WorkersAiImageModel
(String accountId, String modelName, String apiToken) Constructor with Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic WorkersAiImageModel.Builder
builder()
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 dev.langchain4j.model.workersai.client.AbstractWorkersAIModel
processErrors
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.langchain4j.model.image.ImageModel
generate
-
Constructor Details
-
WorkersAiImageModel
Constructor with Builder.- Parameters:
builder
- builder.
-
WorkersAiImageModel
Constructor with Builder.- Parameters:
accountId
- account identifiermodelName
- model nameapiToken
- api token
-
-
Method Details
-
builder
Builder access.- Returns:
- builder instance
-
generate
Given a prompt, generate an image.- Specified by:
generate
in interfaceImageModel
- Parameters:
prompt
- The prompt to generate an image from.- Returns:
- The generated image Response.
-
edit
Given an existing image, edit this image following the given prompt.- Specified by:
edit
in interfaceImageModel
- Parameters:
image
- The image to be edited.prompt
- The prompt to edit the image.- Returns:
- The generated image Response.
-
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:
edit
in 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
Generate image and save to file.- Parameters:
prompt
- current promptdestinationFile
- local file- Returns:
- response with the destination file
-
getPixels
Convert an image into a array of number, supposedly the Pixels.- 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
-