Skip to content

Commit ec91f9e

Browse files
MarkDaoustTest
authored andcommitted
feat: Add interactions support.
Fixes: #1064 PiperOrigin-RevId: 925580578
1 parent 631f4e0 commit ec91f9e

5 files changed

Lines changed: 36 additions & 51 deletions

File tree

10.2 KB
Binary file not shown.

pom.xml

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<junit.version>5.11.4</junit.version>
5555
<java-websocket.version>1.6.0</java-websocket.version>
5656
<okhttp.version>4.12.0</okhttp.version>
57+
<kotlin.version>1.9.10</kotlin.version>
5758
<main.java.src.dir>src/main/java</main.java.src.dir>
5859
<test.java.src.dir>src/test/java</test.java.src.dir>
5960
</properties>
@@ -122,6 +123,11 @@
122123
<artifactId>okhttp</artifactId>
123124
<version>${okhttp.version}</version>
124125
</dependency>
126+
<dependency>
127+
<groupId>org.jetbrains.kotlin</groupId>
128+
<artifactId>kotlin-stdlib-jdk8</artifactId>
129+
<version>1.9.10</version>
130+
</dependency>
125131
<dependency>
126132
<groupId>com.google.protobuf</groupId>
127133
<artifactId>protobuf-java</artifactId>
@@ -158,11 +164,6 @@
158164
<artifactId>jspecify</artifactId>
159165
<version>1.0.0</version>
160166
</dependency>
161-
<dependency>
162-
<groupId>org.jetbrains.kotlin</groupId>
163-
<artifactId>kotlin-stdlib-jdk8</artifactId>
164-
<version>1.9.10</version>
165-
</dependency>
166167
</dependencies>
167168

168169
<build>
@@ -301,6 +302,18 @@
301302
</plugins>
302303
</pluginManagement>
303304
<plugins>
305+
<plugin>
306+
<groupId>org.apache.maven.plugins</groupId>
307+
<artifactId>maven-checkstyle-plugin</artifactId>
308+
<executions>
309+
<execution>
310+
<id>checkstyle</id>
311+
<configuration>
312+
<excludes>**/gaos/**/*.java</excludes>
313+
</configuration>
314+
</execution>
315+
</executions>
316+
</plugin>
304317
<plugin>
305318
<groupId>org.jacoco</groupId>
306319
<artifactId>jacoco-maven-plugin</artifactId>
@@ -391,52 +404,7 @@
391404
</execution>
392405
</executions>
393406
</plugin>
394-
<plugin>
395-
<groupId>org.apache.maven.plugins</groupId>
396-
<artifactId>maven-shade-plugin</artifactId>
397-
<version>3.6.0</version>
398-
<executions>
399-
<execution>
400-
<phase>package</phase>
401-
<goals>
402-
<goal>shade</goal>
403-
</goals>
404-
<configuration>
405-
<artifactSet>
406-
<includes>
407-
<include>org.jetbrains.kotlin:kotlin-stdlib-jdk8</include>
408-
<include>org.jetbrains.kotlin:kotlin-stdlib</include>
409-
<include>org.jetbrains.kotlin:kotlin-reflect</include>
410-
<include>com.fasterxml.jackson.module:jackson-module-kotlin</include>
411-
</includes>
412-
</artifactSet>
413-
<transformers>
414-
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
415-
</transformers>
416-
<relocations>
417-
<relocation>
418-
<pattern>kotlin.</pattern>
419-
<shadedPattern>com.google.genai.shaded.kotlin.</shadedPattern>
420-
</relocation>
421-
<relocation>
422-
<pattern>com.fasterxml.jackson.module.kotlin.</pattern>
423-
<shadedPattern>com.google.genai.shaded.jackson.module.kotlin.</shadedPattern>
424-
</relocation>
425-
</relocations>
426-
<filters>
427-
<filter>
428-
<artifact>*:*</artifact>
429-
<excludes>
430-
<exclude>META-INF/*.SF</exclude>
431-
<exclude>META-INF/*.DSA</exclude>
432-
<exclude>META-INF/*.RSA</exclude>
433-
</excludes>
434-
</filter>
435-
</filters>
436-
</configuration>
437-
</execution>
438-
</executions>
439-
</plugin>
407+
440408
<plugin>
441409
<groupId>org.codehaus.mojo</groupId>
442410
<artifactId>build-helper-maven-plugin</artifactId>
@@ -456,9 +424,17 @@
456424
</execution>
457425
</executions>
458426
</plugin>
427+
<plugin>
428+
<groupId>org.codehaus.mojo</groupId>
429+
<artifactId>animal-sniffer-maven-plugin</artifactId>
430+
<configuration>
431+
<skip>true</skip>
432+
</configuration>
433+
</plugin>
459434
</plugins>
460435
</build>
461436
<profiles>
437+
462438
<profile>
463439
<id>jdk8-build</id>
464440
<activation>

src/main/java/com/google/genai/ApiClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public abstract class ApiClient implements AutoCloseable {
7777
HttpOptions httpOptions;
7878
final boolean vertexAI;
7979
final Optional<ClientOptions> clientOptions;
80+
8081
final Optional<String> customBaseUrl;
8182
// For Google AI APIs
8283
final Optional<String> apiKey;
@@ -120,6 +121,7 @@ protected ApiClient(
120121
}
121122

122123
this.httpClient = createHttpClient(httpOptions, clientOptions);
124+
123125
}
124126

125127
ApiClient(
@@ -274,6 +276,7 @@ protected ApiClient(
274276
}
275277
this.vertexAI = true;
276278
this.httpClient = createHttpClient(httpOptions, clientOptions);
279+
277280
}
278281

279282
private OkHttpClient createHttpClient(
@@ -371,6 +374,8 @@ private void applyProxyOptions(ProxyOptions proxyOptions, OkHttpClient.Builder b
371374
}
372375
}
373376

377+
378+
374379
/** Builds a HTTP request given the http method, path, and request json string. */
375380
@SuppressWarnings("unchecked")
376381
protected Request buildRequest(
@@ -910,6 +915,7 @@ public void close() {
910915
if (httpClient().cache() != null) {
911916
httpClient().cache().close();
912917
}
918+
913919
} catch (IOException e) {
914920
throw new GenAiIOException("Failed to close the client.", e);
915921
}

src/main/java/com/google/genai/Client.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,13 @@ private Client(
315315
caches = new Caches(apiClient);
316316
operations = new Operations(this.apiClient);
317317
chats = new Chats(this.apiClient);
318+
318319
async = new Async(this.apiClient);
319320
files = new Files(this.apiClient);
320321
authTokens = new Tokens(this.apiClient);
321322
tunings = new Tunings(this.apiClient);
322323
fileSearchStores = new FileSearchStores(this.apiClient);
324+
323325
}
324326

325327
/** Returns whether the client is using Vertex AI APIs. */

src/test/java/com/google/genai/HttpApiClientTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,6 +1758,7 @@ public void testCloseClient() {
17581758

17591759
assertTrue(client.httpClient().dispatcher().executorService().isShutdown());
17601760
assertEquals(0, client.httpClient().connectionPool().connectionCount());
1761+
17611762
}
17621763

17631764
@Test

0 commit comments

Comments
 (0)