Class ImagePart
java.lang.Object
com.codename1.ai.MessagePart
com.codename1.ai.ImagePart
Image content within a multimodal
ChatMessage. An image is either
inline encoded bytes with a MIME type or a provider-accessible URL. Inline
bytes are copied on construction and access so later caller mutations
cannot change a request that already contains this part.-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ImagePart
Creates an inline image part. The media type must describe the encoded bytes, for exampleimage/pngorimage/jpeg; providers reject inline images without a type.- Parameters:
data- encoded image bytes, defensively copiedmimeType- media type such asimage/png
-
ImagePart
Remote image by URL. Only HTTPS is portable across providers. Creates a remotely addressed image part.- Parameters:
url- provider-accessible HTTPS or data URL
-
-
Method Details
-
getData
public byte[] getData()- Returns:
- a defensive copy of inline bytes, or
nullfor a URL image
-
getMimeType
- Returns:
- MIME type of inline bytes, or
nullfor a URL image
-
getUrl
- Returns:
- provider-accessible URL, or
nullfor an inline image
-
isUrl
public boolean isUrl()- Returns:
truewhen this part references a URL instead of bytes
-