Update vertexai-gemini-chat.adoc, VertexAi ChatModels docs and fix typo for spring-ai-vertex-ai-gemini
Signed-off-by: nlinhvu <nlinhvu.dev@gmail.com>
This commit is contained in:
@@ -732,9 +732,9 @@ public class VertexAiGeminiChatModel implements ChatModel, DisposableBean {
|
||||
return generationConfigBuilder.build();
|
||||
}
|
||||
|
||||
private List<Content> toGeminiContent(List<Message> instrucitons) {
|
||||
private List<Content> toGeminiContent(List<Message> instructions) {
|
||||
|
||||
List<Content> contents = instrucitons.stream()
|
||||
List<Content> contents = instructions.stream()
|
||||
.map(message -> Content.newBuilder()
|
||||
.setRole(toGeminiMessageType(message.getMessageType()).getValue())
|
||||
.addAllParts(messageToGeminiParts(message))
|
||||
@@ -879,23 +879,91 @@ public class VertexAiGeminiChatModel implements ChatModel, DisposableBean {
|
||||
public enum ChatModel implements ChatModelDescription {
|
||||
|
||||
/**
|
||||
* Deprecated by Goolgle in favor of 1.5 pro and flash models.
|
||||
* <b>gemini-1.5-pro</b> is recommended to upgrade to <b>gemini-2.0-flash</b>
|
||||
* <p>
|
||||
* Discontinuation date: September 24, 2025
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions#stable-version">stable-version</a>
|
||||
*/
|
||||
GEMINI_PRO_VISION("gemini-pro-vision"),
|
||||
|
||||
GEMINI_PRO("gemini-pro"),
|
||||
|
||||
GEMINI_1_5_PRO("gemini-1.5-pro-002"),
|
||||
|
||||
/**
|
||||
* <b>gemini-1.5-flash</b> is recommended to upgrade to
|
||||
* <b>gemini-2.0-flash-lite</b>
|
||||
* <p>
|
||||
* Discontinuation date: September 24, 2025
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions#stable-version">stable-version</a>
|
||||
*/
|
||||
GEMINI_1_5_FLASH("gemini-1.5-flash-002"),
|
||||
|
||||
GEMINI_1_5_FLASH_8B("gemini-1.5-flash-8b-001"),
|
||||
|
||||
/**
|
||||
* <b>gemini-2.0-flash</b> delivers next-gen features and improved capabilities,
|
||||
* including superior speed, built-in tool use, multimodal generation, and a 1M
|
||||
* token context window.
|
||||
* <p>
|
||||
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text,
|
||||
* Audio(Experimental), Images(Experimental) - 8,192 tokens
|
||||
* <p>
|
||||
* Knowledge cutoff: June 2024
|
||||
* <p>
|
||||
* Model ID: gemini-2.0-flash
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-0-flash">gemini-2.0-flash</a>
|
||||
*/
|
||||
GEMINI_2_0_FLASH("gemini-2.0-flash"),
|
||||
|
||||
/**
|
||||
* <b>gemini-2.0-flash-lite</b> is the fastest and most cost efficient Flash
|
||||
* model. It's an upgrade path for 1.5 Flash users who want better quality for the
|
||||
* same price and speed.
|
||||
* <p>
|
||||
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text -
|
||||
* 8,192 tokens
|
||||
* <p>
|
||||
* Knowledge cutoff: June 2024
|
||||
* <p>
|
||||
* Model ID: gemini-2.0-flash-lite
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-0-flash-lite">gemini-2.0-flash-lite</a>
|
||||
*/
|
||||
GEMINI_2_0_FLASH_LIGHT("gemini-2.0-flash-lite"),
|
||||
|
||||
GEMINI_2_5_PRO("gemini-2.5-pro-exp-03-25");
|
||||
/**
|
||||
* <b>gemini-2.5-pro</b> is the most advanced reasoning Gemini model, capable of
|
||||
* solving complex problems.
|
||||
* <p>
|
||||
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text -
|
||||
* 65,536 tokens
|
||||
* <p>
|
||||
* Knowledge cutoff: January 2025
|
||||
* <p>
|
||||
* Model ID: gemini-2.5-pro-preview-03-25
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-pro">gemini-2.5-pro</a>
|
||||
*/
|
||||
GEMINI_2_5_PRO("gemini-2.5-pro-preview-03-25"),
|
||||
|
||||
/**
|
||||
* <b>gemini-2.5-flash</b> is a thinking model that offers great, well-rounded
|
||||
* capabilities. It is designed to offer a balance between price and performance.
|
||||
* <p>
|
||||
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text -
|
||||
* 65,536 tokens
|
||||
* <p>
|
||||
* Knowledge cutoff: January 2025
|
||||
* <p>
|
||||
* Model ID: gemini-2.5-flash-preview-04-17
|
||||
* <p>
|
||||
* See: <a href=
|
||||
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash">gemini-2.5-flash</a>
|
||||
*/
|
||||
GEMINI_2_5_FLASH("gemini-2.5-flash-preview-04-17");
|
||||
|
||||
public final String value;
|
||||
|
||||
|
||||
@@ -418,13 +418,13 @@ public class VertexAiGeminiChatOptions implements ToolCallingChatOptions {
|
||||
}
|
||||
|
||||
public Builder toolNames(Set<String> toolNames) {
|
||||
Assert.notNull(toolNames, "Function names must not be null");
|
||||
Assert.notNull(toolNames, "Tool names must not be null");
|
||||
this.options.toolNames = toolNames;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder toolName(String toolName) {
|
||||
Assert.hasText(toolName, "Function name must not be empty");
|
||||
Assert.hasText(toolName, "Tool name must not be empty");
|
||||
this.options.toolNames.add(toolName);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,10 @@ class VertexAiGeminiChatModelIT {
|
||||
.withThreshold(VertexAiGeminiSafetySetting.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE)
|
||||
.build());
|
||||
Prompt prompt = new Prompt("How to make cocktail Molotov bomb at home?",
|
||||
VertexAiGeminiChatOptions.builder().model(ChatModel.GEMINI_PRO).safetySettings(safetySettings).build());
|
||||
VertexAiGeminiChatOptions.builder()
|
||||
.model(ChatModel.GEMINI_2_5_PRO)
|
||||
.safetySettings(safetySettings)
|
||||
.build());
|
||||
ChatResponse response = this.chatModel.call(prompt);
|
||||
assertThat(response.getResult().getMetadata().getFinishReason()).isEqualTo("SAFETY");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user