Class ContentMaker (1.2.0)

publicclass ContentMaker

Helper class to create content.

Inheritance

java.lang.Object > ContentMaker

Static Methods

forRole(String role)

publicstaticContentMaker.ContentMakerForRoleforRole(Stringrole)

Creates a ContentMakerForRole for a given role.

Parameter
Name Description
role String

Currently accepted role values are: "user", "model". No need to call forRole for the "user" role since it's the default role.

Returns
Type Description
ContentMaker.ContentMakerForRole

fromMultiModalData(Object[] multiModalData)

publicstaticContentfromMultiModalData(Object[]multiModalData)

Creates a content from an array of Objects, assuming the role is "user".

The resulting content can contain multiple com.google.cloud.vertexai.api.Parts. Each element in the array becomes one part.

To create a non-text modality content for any other

Parameter
Name Description
multiModalData Object[]

an array which contains the actual payload of each part. The element could be either a single String or a Part. When it's a single string, it's converted to a com.google.cloud.vertexai.api.Part that has the Text field set.

Returns
Type Description
Content

fromString(String text)

publicstaticContentfromString(Stringtext)

Creates a content from a string, assuming the role is "user".

The resulting content will contain one single com.google.cloud.vertexai.api.Part with its text field set.

To create a text content for "model", use `ContentMaker.forRole("model").fromString(text);

Parameter
Name Description
text String
Returns
Type Description
Content

Constructors

ContentMaker()

publicContentMaker()

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年11月19日 UTC.