Part

public abstract class Part extends JsonSerializable

A datatype containing media content.

Exactly one field within a Part should be set, representing the specific type of content being conveyed. Using multiple fields within the same `Part` instance is considered invalid.

Constructors

Link copied to clipboard
public void Part()

Types

Link copied to clipboard
public abstract class Builder
Builder for Part.

Properties

Link copied to clipboard
public final static String MAX_READ_LENGTH_PROPERTY
System property to override the default max JSON string length (20MB) in read constraints.

Functions

Link copied to clipboard
public static Part.Builder builder()
Instantiates a builder for Part.
Link copied to clipboard
Optional.
Link copied to clipboard
Optional.
Link copied to clipboard
public abstract Optional<FileData> fileData()
Optional.
Link copied to clipboard
public static Part fromBytes(Array<byte> bytes, String mimeType)
Constructs a InlineData Part from a byte array and MIME type.
Link copied to clipboard
public static Part fromFunctionCall(String name, Map<String, Object> args)
Constructs a FunctionCall Part from a function name and args.
Link copied to clipboard
public static Part fromFunctionResponse(String name, Map<String, Object> response, Array<FunctionResponsePart> functionResponseParts)
Constructs a FunctionResponse Part from a function name, response and function response parts.
Link copied to clipboard
public static Part fromJson(String jsonString)
Deserializes a JSON string to a Part object.
Link copied to clipboard
@InternalApi()
public static T fromJsonNode<T extends JsonSerializable>(JsonNode jsonNode, Class<T> clazz)
Deserializes a JsonNode to an object of the given type.
Link copied to clipboard
@InternalApi()
public static T fromJsonString<T extends JsonSerializable>(String jsonString, Class<T> clazz)
Deserializes a Json string to an object of the given type.
Link copied to clipboard
public static Part fromText(String text)
Constructs a Text Part from a text string.
Link copied to clipboard
public static Part fromUri(String fileUri, String mimeType)
Constructs a FileData Part from a file URI and MIME type.
Link copied to clipboard
public abstract Optional<FunctionCall> functionCall()
Optional.
Link copied to clipboard
Optional.
Link copied to clipboard
public abstract Optional<Blob> inlineData()
Optional.
Link copied to clipboard
Media resolution for the input media.
Link copied to clipboard
public static ObjectMapper objectMapper()
Link copied to clipboard
public abstract Optional<Map<String, Object>> partMetadata()
Custom metadata associated with the Part.
Link copied to clipboard
public static void setMaxReadLength(int maxReadLength)
Overrides the default maximum JSON string length (20MB) for the JSON parser.
Link copied to clipboard
public static JsonNode stringToJsonNode(String string)
Converts a Json string to a JsonNode.
Link copied to clipboard
public abstract Optional<String> text()
Optional.
Link copied to clipboard
public abstract Optional<Boolean> thought()
Optional.
Link copied to clipboard
public abstract Optional<Array<byte>> thoughtSignature()
Optional.
Link copied to clipboard
public abstract Part.Builder toBuilder()
Creates a builder with the same values as this instance.
Link copied to clipboard
public String toJson()
Serializes the instance to a Json string.
Link copied to clipboard
public static JsonNode toJsonNode(Object object)
Serializes an object to a JsonNode.
Link copied to clipboard
public static String toJsonString(Object object)
Serializes an object to a Json string.
Link copied to clipboard
public abstract Optional<ToolCall> toolCall()
Server-side tool call.
Link copied to clipboard
public abstract Optional<ToolResponse> toolResponse()
The output from a server-side ToolCall execution.
Link copied to clipboard
Optional.