Class GenerativeModel (0.6.0)
Stay organized with collections
Save and categorize content based on your preferences.
publicclass GenerativeModelThis class holds a generative model that can complete what you provided.
Inherited Members
Static Methods
newBuilder()
publicstaticGenerativeModel.BuildernewBuilder()| Returns | |
|---|---|
| Type | Description |
GenerativeModel.Builder |
|
Constructors
GenerativeModel(String modelName, VertexAI vertexAi)
publicGenerativeModel(StringmodelName,VertexAIvertexAi)Construct a GenerativeModel instance.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro", where "gemini-pro" is the model name. Valid model names can be found at https://cloud.google.com/vertex-ai/docs/generative-ai/learn/models#gemini-models |
vertexAi |
VertexAI |
GenerativeModel(String modelName, VertexAI vertexAi, Transport transport)
publicGenerativeModel(StringmodelName,VertexAIvertexAi,Transporttransport)Construct a GenerativeModel instance.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro" |
vertexAi |
VertexAI |
transport |
Transport the Transport layer for API calls in the generative model. It overrides the transport setting in com.google.cloud.vertexai.VertexAI |
GenerativeModel(String modelName, GenerationConfig generationConfig, VertexAI vertexAi)
publicGenerativeModel(StringmodelName,GenerationConfiggenerationConfig,VertexAIvertexAi)Construct a GenerativeModel instance with default generation config.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro" |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance that will be used by default for generating response |
vertexAi |
VertexAI |
GenerativeModel(String modelName, GenerationConfig generationConfig, VertexAI vertexAi, Transport transport)
publicGenerativeModel(StringmodelName,GenerationConfiggenerationConfig,VertexAIvertexAi,Transporttransport)Construct a GenerativeModel instance with default generation config.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro" |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance that will be used by default for generating response |
vertexAi |
VertexAI |
transport |
Transport the Transport layer for API calls in the generative model. It overrides the transport setting in com.google.cloud.vertexai.VertexAI |
GenerativeModel(String modelName, GenerationConfig generationConfig, List<SafetySetting> safetySettings, VertexAI vertexAi)
publicGenerativeModel(StringmodelName,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings,VertexAIvertexAi)Construct a GenerativeModel instance with default generation config and safety settings.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro" |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance that will be used by default for generating response |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting instances that will be used by default for generating response |
vertexAi |
VertexAI |
GenerativeModel(String modelName, GenerationConfig generationConfig, List<SafetySetting> safetySettings, VertexAI vertexAi, Transport transport)
publicGenerativeModel(StringmodelName,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings,VertexAIvertexAi,Transporttransport)Construct a GenerativeModel instance with default generation config and safety settings.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro" |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance that will be used by default for generating response |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting instances that will be used by default for generating response |
vertexAi |
VertexAI |
transport |
Transport the Transport layer for API calls in the generative model. It overrides the transport setting in com.google.cloud.vertexai.VertexAI |
GenerativeModel(String modelName, List<SafetySetting> safetySettings, VertexAI vertexAi)
publicGenerativeModel(StringmodelName,List<SafetySetting>safetySettings,VertexAIvertexAi)Construct a GenerativeModel instance with default safety settings.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro" |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting instances that will be used by default for generating response |
vertexAi |
VertexAI |
GenerativeModel(String modelName, List<SafetySetting> safetySettings, VertexAI vertexAi, Transport transport)
publicGenerativeModel(StringmodelName,List<SafetySetting>safetySettings,VertexAIvertexAi,Transporttransport)Construct a GenerativeModel instance with default safety settings.
| Parameters | |
|---|---|
| Name | Description |
modelName |
String the name of the generative model. Supported format: "gemini-pro", "models/gemini-pro", "publishers/google/models/gemini-pro" |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting instances that will be used by default for generating response |
vertexAi |
VertexAI |
transport |
Transport the Transport layer for API calls in the generative model. It overrides the transport setting in com.google.cloud.vertexai.VertexAI |
Methods
countTokens(Content content)
publicCountTokensResponsecountTokens(Contentcontent)Count tokens in a single content.
| Parameter | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to count tokens |
| Returns | |
|---|---|
| Type | Description |
CountTokensResponse |
a com.google.cloud.vertexai.api.CountTokensResponse instance that contains the total tokens and total billable characters of the given list of contents |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
countTokens(String text)
publicCountTokensResponsecountTokens(Stringtext)Count tokens in a text message.
| Parameter | |
|---|---|
| Name | Description |
text |
String a text message to count tokens |
| Returns | |
|---|---|
| Type | Description |
CountTokensResponse |
a com.google.cloud.vertexai.api.CountTokensResponse instance that contains the total tokens and total billable characters of the given list of contents |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
countTokens(List<Content> contents)
publicCountTokensResponsecountTokens(List<Content>contents)Count tokens in a list of contents.
| Parameter | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to count tokens |
| Returns | |
|---|---|
| Type | Description |
CountTokensResponse |
a com.google.cloud.vertexai.api.CountTokensResponse instance that contains the total tokens and total billable characters of the given list of contents |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(Content content)
publicGenerateContentResponsegenerateContent(Contentcontent)Generate content from this model given a single content.
| Parameter | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(Content content, GenerationConfig generationConfig) (deprecated)
publicGenerateContentResponsegenerateContent(Contentcontent,GenerationConfiggenerationConfig)Deprecated. use #generateContent(Content, GenerateContentConfig) instead
Generate content from this model given a single content and generation config.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(Content content, GenerationConfig generationConfig, List<SafetySetting> safetySettings) (deprecated)
publicGenerateContentResponsegenerateContent(Contentcontent,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings)Deprecated. use #generateContent(Content, GenerateContentConfig) instead
Generate content from generative model given a single content, generation config, and safety settings.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(Content content, GenerateContentConfig config)
publicGenerateContentResponsegenerateContent(Contentcontent,GenerateContentConfigconfig)Generates content from generative model given a single content and configs.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
config |
GenerateContentConfig a GenerateContentConfig that contains all the configs in making a generate content api call |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(Content content, List<SafetySetting> safetySettings) (deprecated)
publicGenerateContentResponsegenerateContent(Contentcontent,List<SafetySetting>safetySettings)Deprecated. use #generateContent(Content, GenerateContentConfig) instead
Generate content from this model given a single content and safety settings.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(String text)
publicGenerateContentResponsegenerateContent(Stringtext)Generate content from generative model given a text.
| Parameter | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(String text, GenerationConfig generationConfig) (deprecated)
publicGenerateContentResponsegenerateContent(Stringtext,GenerationConfiggenerationConfig)Deprecated. use #generateContent(String, GenerateContentConfig) instead
Generate content from generative model given a text and generation config.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(String text, GenerationConfig generationConfig, List<SafetySetting> safetySettings) (deprecated)
publicGenerateContentResponsegenerateContent(Stringtext,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings)Deprecated. use #generateContent(String, GenerateContentConfig) instead
Generate content from generative model given a text, generation config, and safety settings.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(String text, GenerateContentConfig config)
publicGenerateContentResponsegenerateContent(Stringtext,GenerateContentConfigconfig)Generates content from generative model given a text and configs.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
config |
GenerateContentConfig a GenerateContentConfig that contains all the configs in making a generate content api call |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(String text, List<SafetySetting> safetySettings) (deprecated)
publicGenerateContentResponsegenerateContent(Stringtext,List<SafetySetting>safetySettings)Deprecated. use #generateContent(String, GenerateContentConfig) instead
Generate content from generative model given a text and safety settings.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(List<Content> contents)
publicGenerateContentResponsegenerateContent(List<Content>contents)Generate content from this model given a list of contents.
| Parameter | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(List<Content> contents, GenerationConfig generationConfig) (deprecated)
publicGenerateContentResponsegenerateContent(List<Content>contents,GenerationConfiggenerationConfig)Deprecated. use <xref uid="#generateContent(List<Content>, GenerateContentConfig)" data-throw-if-not-resolved="false">#generateContent(List<Content>, GenerateContentConfig) instead
Generate content from this model given a list of contents and generation config.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(List<Content> contents, GenerationConfig generationConfig, List<SafetySetting> safetySettings) (deprecated)
publicGenerateContentResponsegenerateContent(List<Content>contents,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings)Deprecated. use <xref uid="#generateContent(List<Content>, GenerateContentConfig)" data-throw-if-not-resolved="false">#generateContent(List<Content>, GenerateContentConfig) instead
Generate content from generative model given a list of contents, generation config, and safety settings.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(List<Content> contents, GenerateContentConfig config)
publicGenerateContentResponsegenerateContent(List<Content>contents,GenerateContentConfigconfig)Generates content from generative model given a list of contents and configs.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
config |
GenerateContentConfig a GenerateContentConfig that contains all the configs in making a generate content api call |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContent(List<Content> contents, List<SafetySetting> safetySettings) (deprecated)
publicGenerateContentResponsegenerateContent(List<Content>contents,List<SafetySetting>safetySettings)Deprecated. use <xref uid="#generateContent(List<Content>, GenerateContentConfig)" data-throw-if-not-resolved="false">#generateContent(List<Content>, GenerateContentConfig) instead
Generate content from this model given a list of contents and safety settings.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
GenerateContentResponse |
a com.google.cloud.vertexai.api.GenerateContentResponse instance that contains response contents and other metadata |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(Content content)
publicResponseStream<GenerateContentResponse>generateContentStream(Contentcontent)Generate content with streaming support from generative model given a single Content.
| Parameter | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model. The role of the content is "user". |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(Content content, GenerationConfig generationConfig) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(Contentcontent,GenerationConfiggenerationConfig)Deprecated. use #generateContentStream(Content, GenerateContentConfig) instead
Generate content with streaming support from generative model given a single Content and generation config.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(Content content, GenerationConfig generationConfig, List<SafetySetting> safetySettings) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(Contentcontent,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings)Deprecated. use #generateContentStream(Content, GenerateContentConfig) instead
Generate content with streaming support from generative model given a single content, generation config, and safety settings.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(Content content, GenerateContentConfig config)
publicResponseStream<GenerateContentResponse>generateContentStream(Contentcontent,GenerateContentConfigconfig)Generate content with streaming support from generative model given a single content and configs.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
config |
GenerateContentConfig a GenerateContentConfig that contains all the configs in making a generate content api call |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(Content content, List<SafetySetting> safetySettings) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(Contentcontent,List<SafetySetting>safetySettings)Deprecated. use #generateContentStream(Content, GenerateContentConfig) instead
Generate content with streaming support from generative model given a single content and safety settings.
| Parameters | |
|---|---|
| Name | Description |
content |
Content a com.google.cloud.vertexai.api.Content to send to the generative model |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(String text)
publicResponseStream<GenerateContentResponse>generateContentStream(Stringtext)Generate content with streaming support from generative model given a text.
| Parameter | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(String text, GenerationConfig generationConfig) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(Stringtext,GenerationConfiggenerationConfig)Deprecated. use #generateContentStream(String, GenerateContentConfig) instead
Generate content with streaming support from generative model given a text and generation config.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(String text, GenerationConfig generationConfig, List<SafetySetting> safetySettings) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(Stringtext,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings)Deprecated. use #generateContentStream(String, GenerateContentConfig) instead
Generate content with streaming support from generative model given a text, generation config, and safety settings.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(String text, GenerateContentConfig config)
publicResponseStream<GenerateContentResponse>generateContentStream(Stringtext,GenerateContentConfigconfig)Generate content with streaming support from generative model given a text and configs.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
config |
GenerateContentConfig a GenerateContentConfig that contains all the configs in making a generate content api call |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(String text, List<SafetySetting> safetySettings) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(Stringtext,List<SafetySetting>safetySettings)Deprecated. use #generateContentStream(String, GenerateContentConfig) instead
Generate content with streaming support from generative model given a text and safety settings.
| Parameters | |
|---|---|
| Name | Description |
text |
String a text message to send to the generative model |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(List<Content> contents)
publicResponseStream<GenerateContentResponse>generateContentStream(List<Content>contents)Generate content with streaming support from generative model given a list of contents.
| Parameter | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(List<Content> contents, GenerationConfig generationConfig) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(List<Content>contents,GenerationConfiggenerationConfig)Deprecated. use <xref uid="#generateContentStream(List<Content>, GenerateContentConfig)" data-throw-if-not-resolved="false">#generateContentStream(List<Content>, GenerateContentConfig) instead
Generate content with streaming support from generative model given a list of contents and generation config.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(List<Content> contents, GenerationConfig generationConfig, List<SafetySetting> safetySettings) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(List<Content>contents,GenerationConfiggenerationConfig,List<SafetySetting>safetySettings)Deprecated. use <xref uid="#generateContentStream(List<Content>, GenerateContentConfig)" data-throw-if-not-resolved="false">#generateContentStream(List<Content>, GenerateContentConfig) instead
Generate content with streaming support from generative model given a list of contents, generation config, and safety settings.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
generationConfig |
GenerationConfig a com.google.cloud.vertexai.api.GenerationConfig instance for generating response. #getGenerationConfig will not be used if this is set |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(List<Content> contents, GenerateContentConfig config)
publicResponseStream<GenerateContentResponse>generateContentStream(List<Content>contents,GenerateContentConfigconfig)Generate content with streaming support from generative model given a list of contents and configs.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
config |
GenerateContentConfig a GenerateContentConfig that contains all the configs in making a generate content api call |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
generateContentStream(List<Content> contents, List<SafetySetting> safetySettings) (deprecated)
publicResponseStream<GenerateContentResponse>generateContentStream(List<Content>contents,List<SafetySetting>safetySettings)Deprecated. use <xref uid="#generateContentStream(List<Content>, GenerateContentConfig)" data-throw-if-not-resolved="false">#generateContentStream(List<Content>, GenerateContentConfig) instead
Generate content with streaming support from generative model given a list of contents and safety settings.
| Parameters | |
|---|---|
| Name | Description |
contents |
List<Content>a list of com.google.cloud.vertexai.api.Content to send to the generative model |
safetySettings |
List<SafetySetting>a list of com.google.cloud.vertexai.api.SafetySetting for generating response. #getSafetySettings will not be used if this is set |
| Returns | |
|---|---|
| Type | Description |
ResponseStream<GenerateContentResponse> |
a ResponseStream that contains a streaming of com.google.cloud.vertexai.api.GenerateContentResponse |
| Exceptions | |
|---|---|
| Type | Description |
IOException |
if an I/O error occurs while making the API call |
getGenerationConfig()
publicGenerationConfiggetGenerationConfig()Returns the com.google.cloud.vertexai.api.GenerationConfig of this generative model.
| Returns | |
|---|---|
| Type | Description |
GenerationConfig |
|
getModelName()
publicStringgetModelName()Returns the model name of this generative model.
| Returns | |
|---|---|
| Type | Description |
String |
|
getSafetySettings()
publicList<SafetySetting>getSafetySettings()Returns a list of com.google.cloud.vertexai.api.SafetySettings of this generative model.
| Returns | |
|---|---|
| Type | Description |
List<SafetySetting> |
|
getTools()
publicList<Tool>getTools()Returns a list of com.google.cloud.vertexai.api.Tool of this generative model.
| Returns | |
|---|---|
| Type | Description |
List<Tool> |
|
getTransport()
publicTransportgetTransport()Returns the Transport layer for API calls in this generative model.
| Returns | |
|---|---|
| Type | Description |
Transport |
|
setGenerationConfig(GenerationConfig generationConfig)
publicvoidsetGenerationConfig(GenerationConfiggenerationConfig)Sets the value for #getGenerationConfig, which will be used by default for generating response.
| Parameter | |
|---|---|
| Name | Description |
generationConfig |
GenerationConfig |
setSafetySettings(List<SafetySetting> safetySettings)
publicvoidsetSafetySettings(List<SafetySetting>safetySettings)Sets the value for #getSafetySettings, which will be used by default for generating response.
| Parameter | |
|---|---|
| Name | Description |
safetySettings |
List<SafetySetting> |
setTools(List<Tool> tools)
publicvoidsetTools(List<Tool>tools)Sets the value for #getTools, which will be used by default for generating response.
| Parameter | |
|---|---|
| Name | Description |
tools |
List<Tool> |
setTransport(Transport transport)
publicvoidsetTransport(Transporttransport)Sets the value for #getTransport, which defines the layer for API calls in this generative model.
| Parameter | |
|---|---|
| Name | Description |
transport |
Transport |
startChat()
publicChatSessionstartChat()| Returns | |
|---|---|
| Type | Description |
ChatSession |
|