Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import com.google.adk.tools.GoogleSearchTool;
LlmAgent rootAgent = LlmAgent.builder()
.name("search_assistant")
.description("An assistant that can search the web.")
.model("gemini-2.0-flash") // Or your preferred models
.model("gemini-2.5-flash") // Or your preferred models
.instruction("You are a helpful assistant. Answer user questions using Google Search when needed.")
.tools(new GoogleSearchTool())
.build();
Expand Down
2 changes: 1 addition & 1 deletion TRANSCRIPTION_CAPABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ FunctionTool transcriptionTool = TranscriptionTool.create();
if (transcriptionTool != null) {
LlmAgent agent = LlmAgent.builder()
.name("audio_agent")
.model("gemini-2.0-flash")
.model("gemini-2.5-flash")
.instruction("Analyze audio files. Use transcribe_audio tool when needed.")
.addTool(transcriptionTool)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
class LangChain4jIntegrationTest {

public static final String CLAUDE_4_6_SONNET = "claude-sonnet-4-6";
public static final String GEMINI_2_0_FLASH = "gemini-2.0-flash";
public static final String GEMINI_2_0_FLASH = "gemini-2.5-flash";
public static final String GPT_4_O_MINI = "gpt-4o-mini";

@Test
Expand Down Expand Up @@ -404,7 +404,7 @@ void testStreamingRunConfig() {
// GoogleAiGeminiStreamingChatModel streamingModel =
// GoogleAiGeminiStreamingChatModel.builder()
// .apiKey(System.getenv("GOOGLE_API_KEY"))
// .modelName("gemini-2.0-flash")
// .modelName("gemini-2.5-flash")
// .build();

LlmAgent agent =
Expand Down
4 changes: 2 additions & 2 deletions contrib/samples/a2a_basic/A2AAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static ImmutableMap<String, Object> rollDie(int sides, ToolContext toolCo
public static final LlmAgent ROLL_AGENT =
LlmAgent.builder()
.name("roll_agent")
.model("gemini-2.0-flash")
.model("gemini-2.5-flash")
.description("Handles rolling dice of different sizes.")
.instruction(
"""
Expand All @@ -48,7 +48,7 @@ public static LlmAgent createRootAgent(String primeAgentBaseUrl) {
BaseAgent primeAgent = createRemoteAgent(primeAgentBaseUrl);
return LlmAgent.builder()
.name("root_agent")
.model("gemini-2.0-flash")
.model("gemini-2.5-flash")
.instruction(
"""
You can roll dice locally and delegate prime-checking to the remote prime_agent.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
name: hello_world_agent
model: gemini-2.0-flash
model: gemini-2.5-flash
description: hello world agent that can roll a dice and check prime numbers.
instruction: |
You roll dice and answer questions about the outcome of the dice rolls.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
name: search_agent
model: gemini-2.0-flash
model: gemini-2.5-flash
description: 'an agent whose job it is to perform Google search queries and answer questions about the results.'
instruction: You are an agent whose job is to perform Google search queries and answer questions about the results.
tools:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
name: root_agent
model: gemini-2.0-flash
model: gemini-2.5-flash
description: Root agent
instruction: |
If the user query is about life, you should route it to the life sub-agent.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
name: search_agent
model: gemini-2.0-flash
model: gemini-2.5-flash
description: 'an agent whose job it is to perform Google search queries and answer questions about the results.'
instruction: You are an agent whose job is to perform Google search queries and answer questions about the results.
tools:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
name: hello_world_agent
model: gemini-2.0-flash
model: gemini-2.5-flash
description: 'hello world agent that can roll a dice and check prime numbers.'
instruction: |
You roll dice and answer questions about the outcome of the dice rolls.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
name: filesystem_agent
model: gemini-2.0-flash
model: gemini-2.5-flash
instruction: |
You are a file system assistant. Use the provided tools to read, write, search, and manage
files and directories. Ask clarifying questions when unsure about file operations.
Expand Down
2 changes: 1 addition & 1 deletion contrib/samples/helloworld/HelloWorldAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class HelloWorldAgent {
LlmAgent.builder()
.name("data_processing_agent")
.description("hello world agent that can roll a dice and check prime numbers.")
.model("gemini-2.0-flash")
.model("gemini-2.5-flash")
.instruction(
"""
You roll dice and answer questions about the outcome of the dice rolls.
Expand Down
2 changes: 1 addition & 1 deletion contrib/samples/mcpfilesystem/McpFilesystemAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class McpFilesystemAgent {
LlmAgent.builder()
.name("filesystem_agent")
.description("Assistant that performs file operations through the MCP filesystem server.")
.model("gemini-2.0-flash")
.model("gemini-2.5-flash")
.instruction(
"""
You are a file system assistant. Use the provided tools to read, write, search, and manage
Expand Down
2 changes: 1 addition & 1 deletion contrib/spring-ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ The library works with any Spring AI provider:

#### Gemini
- **System Messages:** Only one system message allowed - library automatically combines multiple system messages
- **Model Names:** Use `gemini-2.0-flash`, `gemini-1.5-pro`
- **Model Names:** Use `gemini-2.5-flash`, `gemini-1.5-pro`
- **API Key:** Requires `GOOGLE_API_KEY` environment variable

#### Anthropic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
class SpringAIIntegrationTest {

public static final String GEMINI_2_5_FLASH = "gemini-2.0-flash";
public static final String GEMINI_2_5_FLASH = "gemini-2.5-flash";

@Test
void testSimpleAgentWithDummyChatModel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.springframework.ai.google.genai.GoogleGenAiChatModel;
Expand All @@ -48,10 +50,30 @@
@EnabledIfEnvironmentVariable(named = "GOOGLE_API_KEY", matches = "\\S+")
class GeminiApiIntegrationTest {

private static final String GEMINI_MODEL = "gemini-2.0-flash";
private static final String GEMINI_MODEL = "gemini-2.5-flash";

private void handlePotentialRateLimit(Throwable t) throws Throwable {
Throwable current = t;
while (current != null) {
if (current.getMessage() != null
&& (current.getMessage().contains("429")
|| current.getMessage().contains("Resource exhausted")
|| current.getMessage().contains("Quota"))) {
Assumptions.assumeTrue(false, "Rate limit exceeded, skipping test");
}
current = current.getCause();
}
throw t;
}

@BeforeEach
void setUp() throws InterruptedException {
// Add delay before each test to avoid rate limiting (429 Resource Exhausted)
Thread.sleep(10000);
}

@Test
void testSimpleAgentWithRealGeminiApi() throws InterruptedException {
void testSimpleAgentWithRealGeminiApi() throws Throwable {
// Add delay to avoid rapid requests
Thread.sleep(2000);

Expand All @@ -77,7 +99,13 @@ void testSimpleAgentWithRealGeminiApi() throws InterruptedException {
.build();

// Test the agent
List<Event> events = TestUtils.askAgent(agent, false, "What is a photon?");
List<Event> events;
try {
events = TestUtils.askAgent(agent, false, "What is a photon?");
} catch (Exception e) {
handlePotentialRateLimit(e);
return;
}

// Verify response
assertThat(events).hasSize(1);
Expand All @@ -94,7 +122,7 @@ void testSimpleAgentWithRealGeminiApi() throws InterruptedException {
}

@Test
void testStreamingWithRealGeminiApi() throws InterruptedException {
void testStreamingWithRealGeminiApi() throws Throwable {
// Add delay to avoid rapid requests
Thread.sleep(2000);

Expand All @@ -121,8 +149,13 @@ void testStreamingWithRealGeminiApi() throws InterruptedException {

// Wait for completion
testSubscriber.awaitDone(30, TimeUnit.SECONDS);
testSubscriber.assertComplete();
testSubscriber.assertNoErrors();
try {
testSubscriber.assertComplete();
testSubscriber.assertNoErrors();
} catch (AssertionError e) {
handlePotentialRateLimit(e);
throw e;
}

// Verify streaming responses
List<LlmResponse> responses = testSubscriber.values();
Expand All @@ -142,7 +175,7 @@ void testStreamingWithRealGeminiApi() throws InterruptedException {
}

@Test
void testAgentWithToolsAndRealApi() {
void testAgentWithToolsAndRealApi() throws Throwable {
Client genAiClient =
Client.builder().apiKey(System.getenv("GOOGLE_API_KEY")).vertexAI(false).build();

Expand All @@ -163,8 +196,13 @@ void testAgentWithToolsAndRealApi() {
.tools(FunctionTool.create(WeatherTools.class, "getWeatherInfo"))
.build();

List<Event> events =
TestUtils.askAgent(agent, false, "What's the weather like in San Francisco?");
List<Event> events;
try {
events = TestUtils.askAgent(agent, false, "What's the weather like in San Francisco?");
} catch (Exception e) {
handlePotentialRateLimit(e);
return;
}

// Should have multiple events: function call, function response, final answer
assertThat(events).hasSizeGreaterThanOrEqualTo(1);
Expand All @@ -185,7 +223,7 @@ void testAgentWithToolsAndRealApi() {
}

@Test
void testDirectComparisonNonStreamingVsStreaming() throws InterruptedException {
void testDirectComparisonNonStreamingVsStreaming() throws Throwable {
// Test both non-streaming and streaming with the same model to compare behavior
Client genAiClient =
Client.builder().apiKey(System.getenv("GOOGLE_API_KEY")).vertexAI(false).build();
Expand All @@ -209,8 +247,13 @@ void testDirectComparisonNonStreamingVsStreaming() throws InterruptedException {
TestSubscriber<LlmResponse> nonStreamingSubscriber =
springAI.generateContent(request, false).test();
nonStreamingSubscriber.awaitDone(30, TimeUnit.SECONDS);
nonStreamingSubscriber.assertComplete();
nonStreamingSubscriber.assertNoErrors();
try {
nonStreamingSubscriber.assertComplete();
nonStreamingSubscriber.assertNoErrors();
} catch (AssertionError e) {
handlePotentialRateLimit(e);
throw e;
}

// Add assertions for non-streaming response
List<LlmResponse> nonStreamingResponses = nonStreamingSubscriber.values();
Expand Down Expand Up @@ -240,8 +283,13 @@ void testDirectComparisonNonStreamingVsStreaming() throws InterruptedException {
TestSubscriber<LlmResponse> streamingSubscriber =
springAI.generateContent(request, true).test();
streamingSubscriber.awaitDone(30, TimeUnit.SECONDS);
streamingSubscriber.assertComplete();
streamingSubscriber.assertNoErrors();
try {
streamingSubscriber.assertComplete();
streamingSubscriber.assertNoErrors();
} catch (AssertionError e) {
handlePotentialRateLimit(e);
throw e;
}

// Add assertions for streaming responses
List<LlmResponse> streamingResponses = streamingSubscriber.values();
Expand Down Expand Up @@ -284,7 +332,7 @@ void testDirectComparisonNonStreamingVsStreaming() throws InterruptedException {
}

@Test
void testConfigurationOptions() {
void testConfigurationOptions() throws Throwable {
// Test with custom configuration
GoogleGenAiChatOptions options =
GoogleGenAiChatOptions.builder()
Expand Down Expand Up @@ -314,8 +362,13 @@ void testConfigurationOptions() {

TestSubscriber<LlmResponse> testSubscriber = springAI.generateContent(request, false).test();
testSubscriber.awaitDone(15, TimeUnit.SECONDS);
testSubscriber.assertComplete();
testSubscriber.assertNoErrors();
try {
testSubscriber.assertComplete();
testSubscriber.assertNoErrors();
} catch (AssertionError e) {
handlePotentialRateLimit(e);
throw e;
}

List<LlmResponse> responses = testSubscriber.values();
assertThat(responses).hasSize(1);
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/com/google/adk/agents/LlmAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public LlmAgent build() {
* <pre>{@code
* LlmAgent.builder()
* .name("MyAgent")
* .model("gemini-2.0-flash-exp")
* .model("gemini-2.5-flash-exp")
* .instruction("You are helpful")
* .toA2aServerAndStart();
* }</pre>
Expand All @@ -639,7 +639,7 @@ public void toA2aServerAndStart() throws IOException, InterruptedException {
* <pre>{@code
* LlmAgent.builder()
* .name("MyAgent")
* .model("gemini-2.0-flash-exp")
* .model("gemini-2.5-flash-exp")
* .instruction("You are helpful")
* .toA2aServerAndStart(5066);
* }</pre>
Expand All @@ -666,7 +666,7 @@ public void toA2aServerAndStart(int port) throws IOException, InterruptedExcepti
* <pre>{@code
* LlmAgent.builder()
* .name("MyAgent")
* .model("gemini-2.0-flash-exp")
* .model("gemini-2.5-flash-exp")
* .instruction("You are helpful")
* .toA2a()
* .port(5066)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,4 @@ private String extractMimeTypeFromPart(Part part) {
public void close() {
dbHelper.close();
}
}
}
8 changes: 4 additions & 4 deletions core/src/main/java/com/google/adk/models/Gemini.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class Gemini extends BaseLlm {
/**
* Constructs a new Gemini instance.
*
* @param modelName The name of the Gemini model to use (e.g., "gemini-2.0-flash").
* @param modelName The name of the Gemini model to use (e.g., "gemini-2.5-flash").
* @param apiClient The genai {@link com.google.genai.Client} instance for making API calls.
*/
public Gemini(String modelName, Client apiClient) {
Expand All @@ -78,7 +78,7 @@ public Gemini(String modelName, Client apiClient) {
/**
* Constructs a new Gemini instance with a Google Gemini API key.
*
* @param modelName The name of the Gemini model to use (e.g., "gemini-2.0-flash").
* @param modelName The name of the Gemini model to use (e.g., "gemini-2.5-flash").
* @param apiKey The Google Gemini API key.
*/
public Gemini(String modelName, String apiKey) {
Expand All @@ -94,7 +94,7 @@ public Gemini(String modelName, String apiKey) {
/**
* Constructs a new Gemini instance with a Google Gemini API key.
*
* @param modelName The name of the Gemini model to use (e.g., "gemini-2.0-flash").
* @param modelName The name of the Gemini model to use (e.g., "gemini-2.5-flash").
* @param vertexCredentials The Vertex AI credentials to access the Gemini model.
*/
public Gemini(String modelName, VertexCredentials vertexCredentials) {
Expand Down Expand Up @@ -131,7 +131,7 @@ private Builder() {}
/**
* Sets the name of the Gemini model to use.
*
* @param modelName The model name (e.g., "gemini-2.0-flash").
* @param modelName The model name (e.g., "gemini-2.5-flash").
* @return This builder.
*/
@CanIgnoreReturnValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public final class GeminiLlmConnection implements BaseLlmConnection {
* Establishes a new connection.
*
* @param apiClient The API client for communication.
* @param modelName The specific Gemini model endpoint (e.g., "gemini-2.0-flash).
* @param modelName The specific Gemini model endpoint (e.g., "gemini-2.5-flash).
* @param connectConfig Configuration parameters for the live session.
*/
GeminiLlmConnection(Client apiClient, String modelName, LiveConnectConfig connectConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,4 +678,4 @@ public ArtifactData(
this.metadata = metadata;
}
}
}
}
Loading
Loading