Skip to content

Commit 50fc122

Browse files
Zhenyi Qicopybara-github
Zhenyi Qi
authored andcommitted
feat: [vertexai] Remove 'preview' namespace and start using @BetaApi
BREAKING_CHANGE: all APIs under preview namespace will be taken out from it and we'll use @BetaApi to align with other java libraries. PiperOrigin-RevId: 604637135
1 parent 5b5bff4 commit 50fc122

File tree

12 files changed

+76
-15
lines changed

12 files changed

+76
-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

+24-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;
@@ -37,6 +38,7 @@ public class ChatSession {
3738
private ResponseStream<GenerateContentResponse> currentResponseStream = null;
3839
private GenerateContentResponse currentResponse = null;
3940

41+
@BetaApi
4042
public ChatSession(GenerativeModel model) {
4143
if (model == null) {
4244
throw new IllegalArgumentException("model should not be null");
@@ -51,6 +53,7 @@ public ChatSession(GenerativeModel model) {
5153
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
5254
* stream by stream() method.
5355
*/
56+
@BetaApi
5457
public ResponseStream<GenerateContentResponse> sendMessageStream(String text) throws IOException {
5558
return sendMessageStream(text, null, null);
5659
}
@@ -63,6 +66,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(String text) th
6366
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
6467
* stream by stream() method.
6568
*/
69+
@BetaApi
6670
public ResponseStream<GenerateContentResponse> sendMessageStream(
6771
String text, GenerationConfig generationConfig) throws IOException {
6872
return sendMessageStream(text, generationConfig, null);
@@ -76,6 +80,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
7680
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
7781
* stream by stream() method.
7882
*/
83+
@BetaApi("safetySettings is a preview feature.")
7984
public ResponseStream<GenerateContentResponse> sendMessageStream(
8085
String text, List<SafetySetting> safetySettings) throws IOException {
8186
return sendMessageStream(text, null, safetySettings);
@@ -90,6 +95,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
9095
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
9196
* stream by stream() method.
9297
*/
98+
@BetaApi("safetySettings is a preview feature.")
9399
public ResponseStream<GenerateContentResponse> sendMessageStream(
94100
String text, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
95101
throws IOException {
@@ -111,6 +117,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
111117
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
112118
* stream by stream() method.
113119
*/
120+
@BetaApi
114121
public ResponseStream<GenerateContentResponse> sendMessageStream(Content content)
115122
throws IOException, IllegalArgumentException {
116123
return sendMessageStream(content, null, null);
@@ -124,6 +131,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(Content content
124131
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
125132
* stream by stream() method.
126133
*/
134+
@BetaApi
127135
public ResponseStream<GenerateContentResponse> sendMessageStream(
128136
Content content, GenerationConfig generationConfig)
129137
throws IOException, IllegalArgumentException {
@@ -138,6 +146,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
138146
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
139147
* stream by stream() method.
140148
*/
149+
@BetaApi("safetySettings is a preview feature.")
141150
public ResponseStream<GenerateContentResponse> sendMessageStream(
142151
Content content, List<SafetySetting> safetySettings)
143152
throws IOException, IllegalArgumentException {
@@ -153,6 +162,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
153162
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
154163
* stream by stream() method.
155164
*/
165+
@BetaApi("safetySettings is a preview feature.")
156166
public ResponseStream<GenerateContentResponse> sendMessageStream(
157167
Content content, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
158168
throws IOException {
@@ -172,6 +182,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
172182
* @param text the message to be sent.
173183
* @return a response.
174184
*/
185+
@BetaApi
175186
public GenerateContentResponse sendMessage(String text) throws IOException {
176187
return sendMessage(text, null, null);
177188
}
@@ -183,6 +194,7 @@ public GenerateContentResponse sendMessage(String text) throws IOException {
183194
* @param generationConfig the generation config.
184195
* @return a response.
185196
*/
197+
@BetaApi
186198
public GenerateContentResponse sendMessage(String text, GenerationConfig generationConfig)
187199
throws IOException {
188200
return sendMessage(text, generationConfig, null);
@@ -195,6 +207,7 @@ public GenerateContentResponse sendMessage(String text, GenerationConfig generat
195207
* @param safetySettings the safety settings.
196208
* @return a response.
197209
*/
210+
@BetaApi("safetySettings is a preview feature.")
198211
public GenerateContentResponse sendMessage(String text, List<SafetySetting> safetySettings)
199212
throws IOException {
200213
return sendMessage(text, null, safetySettings);
@@ -208,6 +221,7 @@ public GenerateContentResponse sendMessage(String text, List<SafetySetting> safe
208221
* @param safetySettings the safety settings.
209222
* @return a response.
210223
*/
224+
@BetaApi("Both sendMessage and safetySettings are preview features.")
211225
public GenerateContentResponse sendMessage(
212226
String text, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
213227
throws IOException {
@@ -227,6 +241,7 @@ public GenerateContentResponse sendMessage(
227241
* @param content the content to be sent.
228242
* @return a response.
229243
*/
244+
@BetaApi
230245
public GenerateContentResponse sendMessage(Content content) throws IOException {
231246
return sendMessage(content, null, null);
232247
}
@@ -238,6 +253,7 @@ public GenerateContentResponse sendMessage(Content content) throws IOException {
238253
* @param generationConfig the generation config.
239254
* @return a response.
240255
*/
256+
@BetaApi
241257
public GenerateContentResponse sendMessage(Content content, GenerationConfig generationConfig)
242258
throws IOException {
243259
return sendMessage(content, generationConfig, null);
@@ -250,6 +266,7 @@ public GenerateContentResponse sendMessage(Content content, GenerationConfig gen
250266
* @param safetySettings the safety settings.
251267
* @return a response.
252268
*/
269+
@BetaApi("Both sendMessage and safetySettings are preview features.")
253270
public GenerateContentResponse sendMessage(Content content, List<SafetySetting> safetySettings)
254271
throws IOException {
255272
return sendMessage(content, null, safetySettings);
@@ -263,6 +280,7 @@ public GenerateContentResponse sendMessage(Content content, List<SafetySetting>
263280
* @param safetySettings the safety settings.
264281
* @return a response.
265282
*/
283+
@BetaApi("Both sendMessage and safetySettings are preview features.")
266284
public GenerateContentResponse sendMessage(
267285
Content content, GenerationConfig generationConfig, List<SafetySetting> safetySettings)
268286
throws IOException {
@@ -326,6 +344,7 @@ private void checkLastResponseAndEditHistory() throws IllegalStateException {
326344
*
327345
* @return an unmodifiable history of the conversation.
328346
*/
347+
@BetaApi
329348
public List<Content> getHistory() {
330349
try {
331350
checkLastResponseAndEditHistory();
@@ -343,6 +362,7 @@ public List<Content> getHistory() {
343362
}
344363

345364
/** Set the history to a list of Content */
365+
@BetaApi
346366
public void setHistory(List<Content> history) {
347367
this.history = history;
348368
}

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;

0 commit comments

Comments
 (0)