Class Part
-
- All Implemented Interfaces:
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public abstract classPart.BuilderBuilder for Part.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description Part()
-
Method Summary
Modifier and Type Method Description abstract Optional<PartMediaResolution>mediaResolution()Media resolution for the input media. abstract Optional<CodeExecutionResult>codeExecutionResult()Optional. abstract Optional<ExecutableCode>executableCode()Optional. abstract Optional<FileData>fileData()Optional. abstract Optional<FunctionCall>functionCall()Optional. abstract Optional<FunctionResponse>functionResponse()Optional. abstract Optional<Blob>inlineData()Optional. abstract Optional<String>text()Optional. abstract Optional<Boolean>thought()Optional. abstract Optional<Array<byte>>thoughtSignature()Optional. abstract Optional<VideoMetadata>videoMetadata()Optional. abstract Optional<ToolCall>toolCall()Server-side tool call. abstract Optional<ToolResponse>toolResponse()The output from a server-side ToolCall execution. abstract Optional<Map<String, Object>>partMetadata()Custom metadata associated with the Part. static Part.Builderbuilder()Instantiates a builder for Part. abstract Part.BuildertoBuilder()Creates a builder with the same values as this instance. static PartfromJson(String jsonString)Deserializes a JSON string to a Part object. static PartfromText(String text)Constructs a Text Part from a text string. static PartfromUri(String fileUri, String mimeType)Constructs a FileData Part from a file URI and MIME type. static PartfromBytes(Array<byte> bytes, String mimeType)Constructs a InlineData Part from a byte array and MIME type. static PartfromFunctionCall(String name, Map<String, Object> args)Constructs a FunctionCall Part from a function name and args. static PartfromFunctionResponse(String name, Map<String, Object> response, Array<FunctionResponsePart> functionResponseParts)Constructs a FunctionResponse Part from a function name, response and function response parts. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
mediaResolution
abstract Optional<PartMediaResolution> mediaResolution()
Media resolution for the input media.
-
codeExecutionResult
abstract Optional<CodeExecutionResult> codeExecutionResult()
Optional. The result of executing the ExecutableCode.
-
executableCode
abstract Optional<ExecutableCode> executableCode()
Optional. Code generated by the model that is intended to be executed.
-
fileData
abstract Optional<FileData> fileData()
Optional. The URI-based data of the part. This can be used to include files from Google Cloud Storage.
-
functionCall
abstract Optional<FunctionCall> functionCall()
Optional. A predicted function call returned from the model. This contains the name of the function to call and the arguments to pass to the function.
-
functionResponse
abstract Optional<FunctionResponse> functionResponse()
Optional. The result of a function call. This is used to provide the model with the result of a function call that it predicted.
-
inlineData
abstract Optional<Blob> inlineData()
Optional. The inline data content of the part. This can be used to include images, audio, or video in a request.
-
text
abstract Optional<String> text()
Optional. The text content of the part. When sent from the VSCode Gemini Code Assist extension, references to @mentioned items will be converted to markdown boldface text. For example `@my-repo` will be converted to and sent as `**my-repo**` by the IDE agent.
-
thought
abstract Optional<Boolean> thought()
Optional. Indicates whether the `part` represents the model's thought process or reasoning.
-
thoughtSignature
abstract Optional<Array<byte>> thoughtSignature()
Optional. An opaque signature for the thought so it can be reused in subsequent requests.
-
videoMetadata
abstract Optional<VideoMetadata> videoMetadata()
Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data.
-
toolCall
abstract Optional<ToolCall> toolCall()
Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API.
-
toolResponse
abstract Optional<ToolResponse> toolResponse()
The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall.
-
partMetadata
abstract Optional<Map<String, Object>> partMetadata()
Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.
-
builder
static Part.Builder builder()
Instantiates a builder for Part.
-
toBuilder
abstract Part.Builder toBuilder()
Creates a builder with the same values as this instance.
-
fromUri
static Part fromUri(String fileUri, String mimeType)
Constructs a FileData Part from a file URI and MIME type.
-
fromBytes
static Part fromBytes(Array<byte> bytes, String mimeType)
Constructs a InlineData Part from a byte array and MIME type.
-
fromFunctionCall
static Part fromFunctionCall(String name, Map<String, Object> args)
Constructs a FunctionCall Part from a function name and args.
-
fromFunctionResponse
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.
-
-
-
-