Class ImageContent
java.lang.Object
dev.langchain4j.data.message.ImageContent
- All Implemented Interfaces:
Content
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe detail level of anImage. -
Constructor Summary
ConstructorsConstructorDescriptionImageContent(Image image) Create a newImageContentfrom the given image.ImageContent(Image image, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given image.ImageContent(String url) Create a newImageContentfrom the given url.ImageContent(String url, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given url and detail level.ImageContent(String base64Data, String mimeType) Create a newImageContentfrom the given base64 data and mime type.ImageContent(String base64Data, String mimeType, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given base64 data and mime type.ImageContent(URI url) Create a newImageContentfrom the given url.ImageContent(URI url, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given url and detail level. -
Method Summary
Modifier and TypeMethodDescriptionGet theDetailLevel.booleanReturns whether the detail level was given when this image content was created.booleanstatic ImageContentCreate a newImageContentfrom the given image.static ImageContentfrom(Image image, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given image.static ImageContentCreate a newImageContentfrom the given url.static ImageContentfrom(String url, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given url and detail level.static ImageContentCreate a newImageContentfrom the given base64 data and mime type.static ImageContentfrom(String base64Data, String mimeType, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given base64 data and mime type.static ImageContentCreate a newImageContentfrom the given url.static ImageContentfrom(URI url, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given url and detail level.static ImageContentCreate a newImageContentfrom the file at the given path and mime type.static ImageContentfrom(Path imageFilePath, String mimeType, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the file at the given path and mime type.inthashCode()image()Get theImage.toString()type()Returns the type of content.
-
Constructor Details
-
ImageContent
Create a newImageContentfrom the given url.The image will be created with
DetailLevel.LOWdetail.- Parameters:
url- the url of the image.
-
ImageContent
Create a newImageContentfrom the given url.The image will be created with
DetailLevel.LOWdetail.- Parameters:
url- the url of the image.
-
ImageContent
Create a newImageContentfrom the given url and detail level.- Parameters:
url- the url of the image.detailLevel- the detail level of the image.
-
ImageContent
Create a newImageContentfrom the given url and detail level.- Parameters:
url- the url of the image.detailLevel- the detail level of the image.
-
ImageContent
Create a newImageContentfrom the given base64 data and mime type.The image will be created with
DetailLevel.LOWdetail.- Parameters:
base64Data- the base64 data of the image.mimeType- the mime type of the image.
-
ImageContent
Create a newImageContentfrom the given base64 data and mime type.- Parameters:
base64Data- the base64 data of the image.mimeType- the mime type of the image.detailLevel- the detail level of the image.
-
ImageContent
Create a newImageContentfrom the given image.The image will be created with
DetailLevel.LOWdetail.- Parameters:
image- the image.
-
ImageContent
Create a newImageContentfrom the given image.- Parameters:
image- the image.detailLevel- the detail level of the image.
-
-
Method Details
-
image
-
detailLevel
-
detailLevelSpecified
Returns whether the detail level was given when this image content was created. When it was not given,detailLevel()returnsImageContent.DetailLevel.LOW. Code that sends the image elsewhere can use this to choose its own detail level only when the creator did not choose one.An image content read from JSON (for example from a stored chat memory) counts as having its detail level given, because the JSON contains the detail level.
This value is not part of
equals(Object),hashCode()ortoString(), and it is not written to JSON.- Returns:
trueif a detail level was given when this image content was created- Since:
- 1.23.0
-
type
Description copied from interface:ContentReturns the type of content.Can be used to cast the content to the correct type.
-
equals
-
hashCode
-
toString
-
from
Create a newImageContentfrom the given url.The image will be created with
DetailLevel.LOWdetail.- Parameters:
url- the url of the image.- Returns:
- the new
ImageContent.
-
from
Create a newImageContentfrom the given url.The image will be created with
DetailLevel.LOWdetail.- Parameters:
url- the url of the image.- Returns:
- the new
ImageContent.
-
from
Create a newImageContentfrom the given url and detail level.- Parameters:
url- the url of the image.detailLevel- the detail level of the image.- Returns:
- the new
ImageContent.
-
from
Create a newImageContentfrom the given url and detail level.- Parameters:
url- the url of the image.detailLevel- the detail level of the image.- Returns:
- the new
ImageContent.
-
from
Create a newImageContentfrom the given base64 data and mime type.The image will be created with
DetailLevel.LOWdetail.- Parameters:
base64Data- the base64 data of the image.mimeType- the mime type of the image.- Returns:
- the new
ImageContent.
-
from
public static ImageContent from(String base64Data, String mimeType, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the given base64 data and mime type.- Parameters:
base64Data- the base64 data of the image.mimeType- the mime type of the image.detailLevel- the detail level of the image.- Returns:
- the new
ImageContent.
-
from
Create a newImageContentfrom the file at the given path and mime type.- Parameters:
imageFilePath- the path to the image file.mimeType- the mime type of the image.- Returns:
- the new
ImageContent.
-
from
public static ImageContent from(Path imageFilePath, String mimeType, ImageContent.DetailLevel detailLevel) Create a newImageContentfrom the file at the given path and mime type.- Parameters:
imageFilePath- the path to the image file.mimeType- the mime type of the image.detailLevel- the detail level of the image.- Returns:
- the new
ImageContent.
-
from
Create a newImageContentfrom the given image.The image will be created with
DetailLevel.LOWdetail.- Parameters:
image- the image.- Returns:
- the new
ImageContent.
-
from
Create a newImageContentfrom the given image.- Parameters:
image- the image.detailLevel- the detail level of the image.- Returns:
- the new
ImageContent.
-