Class ImageContent

java.lang.Object
dev.langchain4j.data.message.ImageContent
All Implemented Interfaces:
Content

public class ImageContent extends Object implements Content
Represents an image with a DetailLevel.
  • Constructor Details

    • ImageContent

      public ImageContent(URI url)
      Create a new ImageContent from the given url.

      The image will be created with DetailLevel.LOW detail.

      Parameters:
      url - the url of the image.
    • ImageContent

      public ImageContent(String url)
      Create a new ImageContent from the given url.

      The image will be created with DetailLevel.LOW detail.

      Parameters:
      url - the url of the image.
    • ImageContent

      public ImageContent(URI url, ImageContent.DetailLevel detailLevel)
      Create a new ImageContent from the given url and detail level.
      Parameters:
      url - the url of the image.
      detailLevel - the detail level of the image.
    • ImageContent

      public ImageContent(String url, ImageContent.DetailLevel detailLevel)
      Create a new ImageContent from the given url and detail level.
      Parameters:
      url - the url of the image.
      detailLevel - the detail level of the image.
    • ImageContent

      public ImageContent(String base64Data, String mimeType)
      Create a new ImageContent from the given base64 data and mime type.

      The image will be created with DetailLevel.LOW detail.

      Parameters:
      base64Data - the base64 data of the image.
      mimeType - the mime type of the image.
    • ImageContent

      public ImageContent(String base64Data, String mimeType, ImageContent.DetailLevel detailLevel)
      Create a new ImageContent from 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

      public ImageContent(Image image)
      Create a new ImageContent from the given image.

      The image will be created with DetailLevel.LOW detail.

      Parameters:
      image - the image.
    • ImageContent

      public ImageContent(Image image, ImageContent.DetailLevel detailLevel)
      Create a new ImageContent from the given image.
      Parameters:
      image - the image.
      detailLevel - the detail level of the image.
  • Method Details

    • image

      public Image image()
      Get the Image.
      Returns:
      the Image.
    • detailLevel

      public ImageContent.DetailLevel detailLevel()
      Get the DetailLevel.
      Returns:
      the DetailLevel.
    • type

      public ContentType type()
      Description copied from interface: Content
      Returns the type of content.

      Can be used to cast the content to the correct type.

      Specified by:
      type in interface Content
      Returns:
      The type of content.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • from

      public static ImageContent from(URI url)
      Create a new ImageContent from the given url.

      The image will be created with DetailLevel.LOW detail.

      Parameters:
      url - the url of the image.
      Returns:
      the new ImageContent.
    • from

      public static ImageContent from(String url)
      Create a new ImageContent from the given url.

      The image will be created with DetailLevel.LOW detail.

      Parameters:
      url - the url of the image.
      Returns:
      the new ImageContent.
    • from

      public static ImageContent from(URI url, ImageContent.DetailLevel detailLevel)
      Create a new ImageContent from 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

      public static ImageContent from(String url, ImageContent.DetailLevel detailLevel)
      Create a new ImageContent from 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

      public static ImageContent from(String base64Data, String mimeType)
      Create a new ImageContent from the given base64 data and mime type.

      The image will be created with DetailLevel.LOW detail.

      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 new ImageContent from 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

      public static ImageContent from(Image image)
      Create a new ImageContent from the given image.

      The image will be created with DetailLevel.LOW detail.

      Parameters:
      image - the image.
      Returns:
      the new ImageContent.
    • from

      public static ImageContent from(Image image, ImageContent.DetailLevel detailLevel)
      Create a new ImageContent from the given image.
      Parameters:
      image - the image.
      detailLevel - the detail level of the image.
      Returns:
      the new ImageContent.