Skip to content

Commit 9907752

Browse files
Zhenyi Qicopybara-github
Zhenyi Qi
authored andcommitted
BREAKING CHANGE: [vertexai] remove namespace 'preview'
PiperOrigin-RevId: 604637135
1 parent e83701b commit 9907752

File tree

12 files changed

+51
-15
lines changed

12 files changed

+51
-15
lines changed

java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/preview/ChatSession.java java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/ChatSession.java

+23-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

19-
import static com.google.cloud.vertexai.generativeai.preview.ResponseHandler.aggregateStreamIntoResponse;
20-
import static com.google.cloud.vertexai.generativeai.preview.ResponseHandler.getContent;
21-
import static com.google.cloud.vertexai.generativeai.preview.ResponseHandler.getFinishReason;
19+
import static com.google.cloud.vertexai.generativeai.ResponseHandler.aggregateStreamIntoResponse;
20+
import static com.google.cloud.vertexai.generativeai.ResponseHandler.getContent;
21+
import static com.google.cloud.vertexai.generativeai.ResponseHandler.getFinishReason;
2222

23+
import com.google.api.core.BetaApi;
2324
import com.google.cloud.vertexai.api.Candidate.FinishReason;
2425
import com.google.cloud.vertexai.api.Content;
2526
import com.google.cloud.vertexai.api.GenerateContentResponse;
@@ -51,6 +52,7 @@ public ChatSession(GenerativeModel model) {
5152
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
5253
* stream by stream() method.
5354
*/
55+
@BetaApi
5456
public ResponseStream<GenerateContentResponse> sendMessageStream(String text) throws IOException {
5557
return sendMessageStream(text, null, null);
5658
}
@@ -63,6 +65,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(String text) th
6365
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
6466
* stream by stream() method.
6567
*/
68+
@BetaApi
6669
public ResponseStream<GenerateContentResponse> sendMessageStream(
6770
String text, GenerationConfig generationConfig) throws IOException {
6871
return sendMessageStream(text, generationConfig, null);
@@ -76,6 +79,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
7679
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
7780
* stream by stream() method.
7881
*/
82+
@BetaApi
7983
public ResponseStream<GenerateContentResponse> sendMessageStream(
8084
String text, List<SafetySetting> safetySettings) throws IOException {
8185
return sendMessageStream(text, null, safetySettings);
@@ -90,6 +94,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
9094
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
9195
* stream by stream() method.
9296
*/
97+
@BetaApi
9398
public ResponseStream<GenerateContentResponse> sendMessageStream(
9499
String text, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
95100
throws IOException {
@@ -111,6 +116,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
111116
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
112117
* stream by stream() method.
113118
*/
119+
@BetaApi
114120
public ResponseStream<GenerateContentResponse> sendMessageStream(Content content)
115121
throws IOException, IllegalArgumentException {
116122
return sendMessageStream(content, null, null);
@@ -124,6 +130,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(Content content
124130
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
125131
* stream by stream() method.
126132
*/
133+
@BetaApi
127134
public ResponseStream<GenerateContentResponse> sendMessageStream(
128135
Content content, GenerationConfig generationConfig)
129136
throws IOException, IllegalArgumentException {
@@ -138,6 +145,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
138145
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
139146
* stream by stream() method.
140147
*/
148+
@BetaApi
141149
public ResponseStream<GenerateContentResponse> sendMessageStream(
142150
Content content, List<SafetySetting> safetySettings)
143151
throws IOException, IllegalArgumentException {
@@ -153,6 +161,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
153161
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
154162
* stream by stream() method.
155163
*/
164+
@BetaApi
156165
public ResponseStream<GenerateContentResponse> sendMessageStream(
157166
Content content, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
158167
throws IOException {
@@ -172,6 +181,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
172181
* @param text the message to be sent.
173182
* @return a response.
174183
*/
184+
@BetaApi
175185
public GenerateContentResponse sendMessage(String text) throws IOException {
176186
return sendMessage(text, null, null);
177187
}
@@ -183,6 +193,7 @@ public GenerateContentResponse sendMessage(String text) throws IOException {
183193
* @param generationConfig the generation config.
184194
* @return a response.
185195
*/
196+
@BetaApi
186197
public GenerateContentResponse sendMessage(String text, GenerationConfig generationConfig)
187198
throws IOException {
188199
return sendMessage(text, generationConfig, null);
@@ -195,6 +206,7 @@ public GenerateContentResponse sendMessage(String text, GenerationConfig generat
195206
* @param safetySettings the safety settings.
196207
* @return a response.
197208
*/
209+
@BetaApi
198210
public GenerateContentResponse sendMessage(String text, List<SafetySetting> safetySettings)
199211
throws IOException {
200212
return sendMessage(text, null, safetySettings);
@@ -208,6 +220,7 @@ public GenerateContentResponse sendMessage(String text, List<SafetySetting> safe
208220
* @param safetySettings the safety settings.
209221
* @return a response.
210222
*/
223+
@BetaApi
211224
public GenerateContentResponse sendMessage(
212225
String text, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
213226
throws IOException {
@@ -227,6 +240,7 @@ public GenerateContentResponse sendMessage(
227240
* @param content the content to be sent.
228241
* @return a response.
229242
*/
243+
@BetaApi
230244
public GenerateContentResponse sendMessage(Content content) throws IOException {
231245
return sendMessage(content, null, null);
232246
}
@@ -238,6 +252,7 @@ public GenerateContentResponse sendMessage(Content content) throws IOException {
238252
* @param generationConfig the generation config.
239253
* @return a response.
240254
*/
255+
@BetaApi
241256
public GenerateContentResponse sendMessage(Content content, GenerationConfig generationConfig)
242257
throws IOException {
243258
return sendMessage(content, generationConfig, null);
@@ -250,6 +265,7 @@ public GenerateContentResponse sendMessage(Content content, GenerationConfig gen
250265
* @param safetySettings the safety settings.
251266
* @return a response.
252267
*/
268+
@BetaApi
253269
public GenerateContentResponse sendMessage(Content content, List<SafetySetting> safetySettings)
254270
throws IOException {
255271
return sendMessage(content, null, safetySettings);
@@ -263,6 +279,7 @@ public GenerateContentResponse sendMessage(Content content, List<SafetySetting>
263279
* @param safetySettings the safety settings.
264280
* @return a response.
265281
*/
282+
@BetaApi
266283
public GenerateContentResponse sendMessage(
267284
Content content, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
268285
throws IOException {
@@ -326,6 +343,7 @@ private void checkLastResponseAndEditHistory() throws IllegalStateException {
326343
*
327344
* @return an unmodifiable history of the conversation.
328345
*/
346+
@BetaApi
329347
public List<Content> getHistory() {
330348
try {
331349
checkLastResponseAndEditHistory();
@@ -343,6 +361,7 @@ public List<Content> getHistory() {
343361
}
344362

345363
/** Set the history to a list of Content */
364+
@BetaApi
346365
public void setHistory(List<Content> history) {
347366
this.history = history;
348367
}

java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/preview/Constants.java java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/Constants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import com.google.common.collect.ImmutableSet;
2020

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import com.google.cloud.vertexai.api.Content;
2020
import com.google.cloud.vertexai.api.Part;
+18-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

19+
import com.google.api.core.BetaApi;
1920
import com.google.cloud.vertexai.Transport;
2021
import com.google.cloud.vertexai.VertexAI;
2122
import com.google.cloud.vertexai.api.Content;
@@ -329,6 +330,7 @@ public GenerativeModel(
329330
* total tokens and total billable characters of the given list of contents
330331
* @throws IOException if an I/O error occurs while making the API call
331332
*/
333+
@BetaApi
332334
public CountTokensResponse countTokens(String text) throws IOException {
333335
Content content = ContentMaker.fromString(text);
334336
CountTokensRequest.Builder requestBuilder =
@@ -344,6 +346,7 @@ public CountTokensResponse countTokens(String text) throws IOException {
344346
* total tokens and total billable characters of the given list of contents
345347
* @throws IOException if an I/O error occurs while making the API call
346348
*/
349+
@BetaApi
347350
public CountTokensResponse countTokens(Content content) throws IOException {
348351
return countTokens(Arrays.asList(content));
349352
}
@@ -356,6 +359,7 @@ public CountTokensResponse countTokens(Content content) throws IOException {
356359
* total tokens and total billable characters of the given list of contents
357360
* @throws IOException if an I/O error occurs while making the API call
358361
*/
362+
@BetaApi
359363
public CountTokensResponse countTokens(List<Content> contents) throws IOException {
360364
CountTokensRequest.Builder requestBuilder =
361365
CountTokensRequest.newBuilder().addAllContents(contents);
@@ -371,6 +375,7 @@ public CountTokensResponse countTokens(List<Content> contents) throws IOExceptio
371375
* total tokens and total billable characters of the given list of contents
372376
* @throws IOException if an I/O error occurs while making the API call
373377
*/
378+
@BetaApi
374379
private CountTokensResponse countTokensFromBuilder(CountTokensRequest.Builder requestBuilder)
375380
throws IOException {
376381
CountTokensRequest request =
@@ -390,6 +395,7 @@ private CountTokensResponse countTokensFromBuilder(CountTokensRequest.Builder re
390395
* response contents and other metadata
391396
* @throws IOException if an I/O error occurs while making the API call
392397
*/
398+
@BetaApi
393399
public GenerateContentResponse generateContent(String text) throws IOException {
394400
return generateContent(text, null, null);
395401
}
@@ -404,6 +410,7 @@ public GenerateContentResponse generateContent(String text) throws IOException {
404410
* response contents and other metadata
405411
* @throws IOException if an I/O error occurs while making the API call
406412
*/
413+
@BetaApi
407414
public GenerateContentResponse generateContent(String text, GenerationConfig generationConfig)
408415
throws IOException {
409416
return generateContent(text, generationConfig, null);
@@ -419,6 +426,7 @@ public GenerateContentResponse generateContent(String text, GenerationConfig gen
419426
* response contents and other metadata
420427
* @throws IOException if an I/O error occurs while making the API call
421428
*/
429+
@BetaApi
422430
public GenerateContentResponse generateContent(String text, List<SafetySetting> safetySettings)
423431
throws IOException {
424432
return generateContent(text, null, safetySettings);
@@ -436,6 +444,7 @@ public GenerateContentResponse generateContent(String text, List<SafetySetting>
436444
* response contents and other metadata
437445
* @throws IOException if an I/O error occurs while making the API call
438446
*/
447+
@BetaApi
439448
public GenerateContentResponse generateContent(
440449
String text, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
441450
throws IOException {
@@ -454,6 +463,7 @@ public GenerateContentResponse generateContent(
454463
* response contents and other metadata
455464
* @throws IOException if an I/O error occurs while making the API call
456465
*/
466+
@BetaApi
457467
public GenerateContentResponse generateContent(List<Content> contents) throws IOException {
458468
return generateContent(contents, null, null);
459469
}
@@ -469,6 +479,7 @@ public GenerateContentResponse generateContent(List<Content> contents) throws IO
469479
* response contents and other metadata
470480
* @throws IOException if an I/O error occurs while making the API call
471481
*/
482+
@BetaApi
472483
public GenerateContentResponse generateContent(
473484
List<Content> contents, GenerationConfig generationConfig) throws IOException {
474485
return generateContent(contents, generationConfig, null);
@@ -485,6 +496,7 @@ public GenerateContentResponse generateContent(
485496
* response contents and other metadata
486497
* @throws IOException if an I/O error occurs while making the API call
487498
*/
499+
@BetaApi
488500
public GenerateContentResponse generateContent(
489501
List<Content> contents, List<SafetySetting> safetySettings) throws IOException {
490502
return generateContent(contents, null, safetySettings);
@@ -504,6 +516,7 @@ public GenerateContentResponse generateContent(
504516
* response contents and other metadata
505517
* @throws IOException if an I/O error occurs while making the API call
506518
*/
519+
@BetaApi
507520
public GenerateContentResponse generateContent(
508521
List<Content> contents, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
509522
throws IOException {
@@ -533,6 +546,7 @@ public GenerateContentResponse generateContent(
533546
* response contents and other metadata
534547
* @throws IOException if an I/O error occurs while making the API call
535548
*/
549+
@BetaApi
536550
public GenerateContentResponse generateContent(Content content) throws IOException {
537551
return generateContent(content, null, null);
538552
}
@@ -547,6 +561,7 @@ public GenerateContentResponse generateContent(Content content) throws IOExcepti
547561
* response contents and other metadata
548562
* @throws IOException if an I/O error occurs while making the API call
549563
*/
564+
@BetaApi
550565
public GenerateContentResponse generateContent(Content content, GenerationConfig generationConfig)
551566
throws IOException {
552567
return generateContent(content, generationConfig, null);
@@ -562,6 +577,7 @@ public GenerateContentResponse generateContent(Content content, GenerationConfig
562577
* response contents and other metadata
563578
* @throws IOException if an I/O error occurs while making the API call
564579
*/
580+
@BetaApi
565581
public GenerateContentResponse generateContent(
566582
Content content, List<SafetySetting> safetySettings) throws IOException {
567583
return generateContent(content, null, safetySettings);
@@ -580,6 +596,7 @@ public GenerateContentResponse generateContent(
580596
* response contents and other metadata
581597
* @throws IOException if an I/O error occurs while making the API call
582598
*/
599+
@BetaApi
583600
public GenerateContentResponse generateContent(
584601
Content content, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
585602
throws IOException {

java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/preview/PartMaker.java java-vertexai/google-cloud-vertexai/src/main/java/com/google/cloud/vertexai/generativeai/PartMaker.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import com.google.cloud.vertexai.api.Blob;
2020
import com.google.cloud.vertexai.api.FileData;
+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import com.google.cloud.vertexai.api.Candidate;
2020
import com.google.cloud.vertexai.api.Candidate.Builder;
+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import com.google.cloud.vertexai.api.GenerateContentResponse;
2020
import java.util.Iterator;
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import com.google.cloud.vertexai.api.GenerateContentResponse;
2020
import java.util.ArrayList;

java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/generativeai/preview/ChatSessionTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static org.junit.Assert.assertThrows;

java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/generativeai/preview/ContentMakerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020

java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/generativeai/preview/PartMakerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static org.junit.Assert.assertThrows;

java-vertexai/google-cloud-vertexai/src/test/java/com/google/cloud/vertexai/generativeai/preview/ResponseHandlerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.google.cloud.vertexai.generativeai.preview;
17+
package com.google.cloud.vertexai.generativeai;
1818

1919
import static com.google.common.truth.Truth.assertThat;
2020
import static org.junit.Assert.assertThrows;

0 commit comments

Comments
 (0)