Skip to content

Commit 8925e69

Browse files
committed
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>
1 parent c0bc623 commit 8925e69

File tree

4 files changed

+128
-48
lines changed

4 files changed

+128
-48
lines changed

models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModel.java

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha
547547

548548
protected List<Generation> responseCandidateToGeneration(Candidate candidate) {
549549

550-
// TODO - The candidateIndex (e.g. choice must be asigned to the generation).
550+
// TODO - The candidateIndex (e.g. choice must be assigned to the generation).
551551
int candidateIndex = candidate.getIndex();
552552
FinishReason candidateFinishReason = candidate.getFinishReason();
553553

@@ -706,9 +706,9 @@ private GenerationConfig toGenerationConfig(VertexAiGeminiChatOptions options) {
706706
return generationConfigBuilder.build();
707707
}
708708

709-
private List<Content> toGeminiContent(List<Message> instrucitons) {
709+
private List<Content> toGeminiContent(List<Message> instructions) {
710710

711-
List<Content> contents = instrucitons.stream()
711+
List<Content> contents = instructions.stream()
712712
.map(message -> Content.newBuilder()
713713
.setRole(toGeminiMessageType(message.getMessageType()).getValue())
714714
.addAllParts(messageToGeminiParts(message))
@@ -853,23 +853,91 @@ public String getValue() {
853853
public enum ChatModel implements ChatModelDescription {
854854

855855
/**
856-
* Deprecated by Goolgle in favor of 1.5 pro and flash models.
856+
* <b>gemini-1.5-pro</b> is recommended to upgrade to <b>gemini-2.0-flash</b>
857+
* <p>
858+
* Discontinuation date: September 24, 2025
859+
* <p>
860+
* See: <a href=
861+
* "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions#stable-version">stable-version</a>
857862
*/
858-
GEMINI_PRO_VISION("gemini-pro-vision"),
859-
860-
GEMINI_PRO("gemini-pro"),
861-
862863
GEMINI_1_5_PRO("gemini-1.5-pro-002"),
863864

865+
/**
866+
* <b>gemini-1.5-flash</b> is recommended to upgrade to
867+
* <b>gemini-2.0-flash-lite</b>
868+
* <p>
869+
* Discontinuation date: September 24, 2025
870+
* <p>
871+
* See: <a href=
872+
* "https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions#stable-version">stable-version</a>
873+
*/
864874
GEMINI_1_5_FLASH("gemini-1.5-flash-002"),
865875

866-
GEMINI_1_5_FLASH_8B("gemini-1.5-flash-8b-001"),
867-
876+
/**
877+
* <b>gemini-2.0-flash</b> delivers next-gen features and improved capabilities,
878+
* including superior speed, built-in tool use, multimodal generation, and a 1M
879+
* token context window.
880+
* <p>
881+
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text,
882+
* Audio(Experimental), Images(Experimental) - 8,192 tokens
883+
* <p>
884+
* Knowledge cutoff: June 2024
885+
* <p>
886+
* Model ID: gemini-2.0-flash
887+
* <p>
888+
* See: <a href=
889+
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-0-flash">gemini-2.0-flash</a>
890+
*/
868891
GEMINI_2_0_FLASH("gemini-2.0-flash"),
869892

893+
/**
894+
* <b>gemini-2.0-flash-lite</b> is the fastest and most cost efficient Flash
895+
* model. It's an upgrade path for 1.5 Flash users who want better quality for the
896+
* same price and speed.
897+
* <p>
898+
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text -
899+
* 8,192 tokens
900+
* <p>
901+
* Knowledge cutoff: June 2024
902+
* <p>
903+
* Model ID: gemini-2.0-flash-lite
904+
* <p>
905+
* See: <a href=
906+
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-0-flash-lite">gemini-2.0-flash-lite</a>
907+
*/
870908
GEMINI_2_0_FLASH_LIGHT("gemini-2.0-flash-lite"),
871909

872-
GEMINI_2_5_PRO("gemini-2.5-pro-exp-03-25");
910+
/**
911+
* <b>gemini-2.5-pro</b> is the most advanced reasoning Gemini model, capable of
912+
* solving complex problems.
913+
* <p>
914+
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text -
915+
* 65,536 tokens
916+
* <p>
917+
* Knowledge cutoff: January 2025
918+
* <p>
919+
* Model ID: gemini-2.5-pro-preview-03-25
920+
* <p>
921+
* See: <a href=
922+
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-pro">gemini-2.5-pro</a>
923+
*/
924+
GEMINI_2_5_PRO("gemini-2.5-pro-preview-03-25"),
925+
926+
/**
927+
* <b>gemini-2.5-flash</b> is a thinking model that offers great, well-rounded
928+
* capabilities. It is designed to offer a balance between price and performance.
929+
* <p>
930+
* Inputs: Text, Code, Images, Audio, Video - 1,048,576 tokens | Outputs: Text -
931+
* 65,536 tokens
932+
* <p>
933+
* Knowledge cutoff: January 2025
934+
* <p>
935+
* Model ID: gemini-2.5-flash-preview-04-17
936+
* <p>
937+
* See: <a href=
938+
* "https://cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash">gemini-2.5-flash</a>
939+
*/
940+
GEMINI_2_5_FLASH("gemini-2.5-flash-preview-04-17");
873941

874942
public final String value;
875943

models/spring-ai-vertex-ai-gemini/src/main/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatOptions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public Builder functions(Set<String> functionNames) {
423423
}
424424

425425
public Builder toolNames(Set<String> toolNames) {
426-
Assert.notNull(toolNames, "Function names must not be null");
426+
Assert.notNull(toolNames, "Tool names must not be null");
427427
this.options.toolNames = toolNames;
428428
return this;
429429
}
@@ -434,7 +434,7 @@ public Builder function(String functionName) {
434434
}
435435

436436
public Builder toolName(String toolName) {
437-
Assert.hasText(toolName, "Function name must not be empty");
437+
Assert.hasText(toolName, "Tool name must not be empty");
438438
this.options.toolNames.add(toolName);
439439
return this;
440440
}

models/spring-ai-vertex-ai-gemini/src/test/java/org/springframework/ai/vertexai/gemini/VertexAiGeminiChatModelIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ void testSafetySettings() {
118118
.withThreshold(VertexAiGeminiSafetySetting.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE)
119119
.build());
120120
Prompt prompt = new Prompt("How to make cocktail Molotov bomb at home?",
121-
VertexAiGeminiChatOptions.builder().model(ChatModel.GEMINI_PRO).safetySettings(safetySettings).build());
121+
VertexAiGeminiChatOptions.builder()
122+
.model(ChatModel.GEMINI_2_5_PRO)
123+
.safetySettings(safetySettings)
124+
.build());
122125
ChatResponse response = this.chatModel.call(prompt);
123126
assertThat(response.getResult().getMetadata().getFinishReason()).isEqualTo("SAFETY");
124127
}

0 commit comments

Comments
 (0)