14
14
* limitations under the License.
15
15
*/
16
16
17
- package com .google .cloud .vertexai .generativeai . preview ;
17
+ package com .google .cloud .vertexai .generativeai ;
18
18
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 ;
22
22
23
+ import com .google .api .core .BetaApi ;
23
24
import com .google .cloud .vertexai .api .Candidate .FinishReason ;
24
25
import com .google .cloud .vertexai .api .Content ;
25
26
import com .google .cloud .vertexai .api .GenerateContentResponse ;
@@ -37,6 +38,7 @@ public class ChatSession {
37
38
private ResponseStream <GenerateContentResponse > currentResponseStream = null ;
38
39
private GenerateContentResponse currentResponse = null ;
39
40
41
+ @ BetaApi
40
42
public ChatSession (GenerativeModel model ) {
41
43
if (model == null ) {
42
44
throw new IllegalArgumentException ("model should not be null" );
@@ -51,6 +53,7 @@ public ChatSession(GenerativeModel model) {
51
53
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
52
54
* stream by stream() method.
53
55
*/
56
+ @ BetaApi
54
57
public ResponseStream <GenerateContentResponse > sendMessageStream (String text ) throws IOException {
55
58
return sendMessageStream (text , null , null );
56
59
}
@@ -63,6 +66,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(String text) th
63
66
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
64
67
* stream by stream() method.
65
68
*/
69
+ @ BetaApi
66
70
public ResponseStream <GenerateContentResponse > sendMessageStream (
67
71
String text , GenerationConfig generationConfig ) throws IOException {
68
72
return sendMessageStream (text , generationConfig , null );
@@ -76,6 +80,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
76
80
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
77
81
* stream by stream() method.
78
82
*/
83
+ @ BetaApi ("safetySettings is a preview feature." )
79
84
public ResponseStream <GenerateContentResponse > sendMessageStream (
80
85
String text , List <SafetySetting > safetySettings ) throws IOException {
81
86
return sendMessageStream (text , null , safetySettings );
@@ -90,6 +95,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
90
95
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
91
96
* stream by stream() method.
92
97
*/
98
+ @ BetaApi ("safetySettings is a preview feature." )
93
99
public ResponseStream <GenerateContentResponse > sendMessageStream (
94
100
String text , GenerationConfig generationConfig , List <SafetySetting > safetySettings )
95
101
throws IOException {
@@ -111,6 +117,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
111
117
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
112
118
* stream by stream() method.
113
119
*/
120
+ @ BetaApi
114
121
public ResponseStream <GenerateContentResponse > sendMessageStream (Content content )
115
122
throws IOException , IllegalArgumentException {
116
123
return sendMessageStream (content , null , null );
@@ -124,6 +131,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(Content content
124
131
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
125
132
* stream by stream() method.
126
133
*/
134
+ @ BetaApi
127
135
public ResponseStream <GenerateContentResponse > sendMessageStream (
128
136
Content content , GenerationConfig generationConfig )
129
137
throws IOException , IllegalArgumentException {
@@ -138,6 +146,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
138
146
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
139
147
* stream by stream() method.
140
148
*/
149
+ @ BetaApi ("safetySettings is a preview feature." )
141
150
public ResponseStream <GenerateContentResponse > sendMessageStream (
142
151
Content content , List <SafetySetting > safetySettings )
143
152
throws IOException , IllegalArgumentException {
@@ -153,6 +162,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
153
162
* @return an iterable in which each element is a GenerateContentResponse. Can be converted to
154
163
* stream by stream() method.
155
164
*/
165
+ @ BetaApi ("safetySettings is a preview feature." )
156
166
public ResponseStream <GenerateContentResponse > sendMessageStream (
157
167
Content content , GenerationConfig generationConfig , List <SafetySetting > safetySettings )
158
168
throws IOException {
@@ -172,6 +182,7 @@ public ResponseStream<GenerateContentResponse> sendMessageStream(
172
182
* @param text the message to be sent.
173
183
* @return a response.
174
184
*/
185
+ @ BetaApi
175
186
public GenerateContentResponse sendMessage (String text ) throws IOException {
176
187
return sendMessage (text , null , null );
177
188
}
@@ -183,6 +194,7 @@ public GenerateContentResponse sendMessage(String text) throws IOException {
183
194
* @param generationConfig the generation config.
184
195
* @return a response.
185
196
*/
197
+ @ BetaApi
186
198
public GenerateContentResponse sendMessage (String text , GenerationConfig generationConfig )
187
199
throws IOException {
188
200
return sendMessage (text , generationConfig , null );
@@ -195,6 +207,7 @@ public GenerateContentResponse sendMessage(String text, GenerationConfig generat
195
207
* @param safetySettings the safety settings.
196
208
* @return a response.
197
209
*/
210
+ @ BetaApi ("safetySettings is a preview feature." )
198
211
public GenerateContentResponse sendMessage (String text , List <SafetySetting > safetySettings )
199
212
throws IOException {
200
213
return sendMessage (text , null , safetySettings );
@@ -208,6 +221,7 @@ public GenerateContentResponse sendMessage(String text, List<SafetySetting> safe
208
221
* @param safetySettings the safety settings.
209
222
* @return a response.
210
223
*/
224
+ @ BetaApi ("Both sendMessage and safetySettings are preview features." )
211
225
public GenerateContentResponse sendMessage (
212
226
String text , GenerationConfig generationConfig , List <SafetySetting > safetySettings )
213
227
throws IOException {
@@ -227,6 +241,7 @@ public GenerateContentResponse sendMessage(
227
241
* @param content the content to be sent.
228
242
* @return a response.
229
243
*/
244
+ @ BetaApi
230
245
public GenerateContentResponse sendMessage (Content content ) throws IOException {
231
246
return sendMessage (content , null , null );
232
247
}
@@ -238,6 +253,7 @@ public GenerateContentResponse sendMessage(Content content) throws IOException {
238
253
* @param generationConfig the generation config.
239
254
* @return a response.
240
255
*/
256
+ @ BetaApi
241
257
public GenerateContentResponse sendMessage (Content content , GenerationConfig generationConfig )
242
258
throws IOException {
243
259
return sendMessage (content , generationConfig , null );
@@ -250,6 +266,7 @@ public GenerateContentResponse sendMessage(Content content, GenerationConfig gen
250
266
* @param safetySettings the safety settings.
251
267
* @return a response.
252
268
*/
269
+ @ BetaApi ("Both sendMessage and safetySettings are preview features." )
253
270
public GenerateContentResponse sendMessage (Content content , List <SafetySetting > safetySettings )
254
271
throws IOException {
255
272
return sendMessage (content , null , safetySettings );
@@ -263,6 +280,7 @@ public GenerateContentResponse sendMessage(Content content, List<SafetySetting>
263
280
* @param safetySettings the safety settings.
264
281
* @return a response.
265
282
*/
283
+ @ BetaApi ("Both sendMessage and safetySettings are preview features." )
266
284
public GenerateContentResponse sendMessage (
267
285
Content content , GenerationConfig generationConfig , List <SafetySetting > safetySettings )
268
286
throws IOException {
@@ -326,6 +344,7 @@ private void checkLastResponseAndEditHistory() throws IllegalStateException {
326
344
*
327
345
* @return an unmodifiable history of the conversation.
328
346
*/
347
+ @ BetaApi
329
348
public List <Content > getHistory () {
330
349
try {
331
350
checkLastResponseAndEditHistory ();
@@ -343,6 +362,7 @@ public List<Content> getHistory() {
343
362
}
344
363
345
364
/** Set the history to a list of Content */
365
+ @ BetaApi
346
366
public void setHistory (List <Content > history ) {
347
367
this .history = history ;
348
368
}
0 commit comments