99
1010import io .weaviate .client6 .v1 .api .collections .Generative ;
1111import io .weaviate .client6 .v1 .api .collections .generate .DynamicProvider ;
12+ import io .weaviate .client6 .v1 .api .collections .vectorizers .Text2VecGoogleVectorizer ;
1213import io .weaviate .client6 .v1 .internal .ObjectBuilder ;
1314import io .weaviate .client6 .v1 .internal .grpc .protocol .WeaviateProtoBase ;
1415import io .weaviate .client6 .v1 .internal .grpc .protocol .WeaviateProtoGenerative ;
@@ -32,12 +33,20 @@ public Object _self() {
3233 return this ;
3334 }
3435
35- public static GoogleGenerative of ( String projectId ) {
36- return of ( projectId , ObjectBuilder .identity ());
36+ public static GoogleGenerative aiStudio ( ) {
37+ return aiStudio ( ObjectBuilder .identity ());
3738 }
3839
39- public static GoogleGenerative of (String projectId , Function <Builder , ObjectBuilder <GoogleGenerative >> fn ) {
40- return fn .apply (new Builder (projectId )).build ();
40+ public static GoogleGenerative aiStudio (Function <AiStudioBuilder , ObjectBuilder <GoogleGenerative >> fn ) {
41+ return fn .apply (new AiStudioBuilder ()).build ();
42+ }
43+
44+ public static GoogleGenerative vertex (String projectId ) {
45+ return vertex (projectId , ObjectBuilder .identity ());
46+ }
47+
48+ public static GoogleGenerative vertex (String projectId , Function <VertexBuilder , ObjectBuilder <GoogleGenerative >> fn ) {
49+ return fn .apply (new VertexBuilder (projectId )).build ();
4150 }
4251
4352 public GoogleGenerative (Builder builder ) {
@@ -51,22 +60,23 @@ public GoogleGenerative(Builder builder) {
5160 builder .temperature );
5261 }
5362
54- public static class Builder implements ObjectBuilder <GoogleGenerative > {
63+ public abstract static class Builder implements ObjectBuilder <GoogleGenerative > {
64+ private String baseUrl ;
5565 private final String projectId ;
5666
57- private String baseUrl ;
5867 private String model ;
5968 private Integer maxTokens ;
6069 private Integer topK ;
6170 private Float topP ;
6271 private Float temperature ;
6372
64- public Builder (String projectId ) {
73+ public Builder (String baseUrl , String projectId ) {
6574 this .projectId = projectId ;
75+ this .baseUrl = baseUrl ;
6676 }
6777
6878 /** Base URL of the generative provider. */
69- public Builder baseUrl (String baseUrl ) {
79+ protected Builder baseUrl (String baseUrl ) {
7080 this .baseUrl = baseUrl ;
7181 return this ;
7282 }
@@ -110,6 +120,24 @@ public GoogleGenerative build() {
110120 }
111121 }
112122
123+ public static class AiStudioBuilder extends Builder {
124+ public AiStudioBuilder () {
125+ super (Text2VecGoogleVectorizer .AiStudioBuilder .BASE_URL , null );
126+ }
127+ }
128+
129+ public static class VertexBuilder extends Builder {
130+ public VertexBuilder (String projectId ) {
131+ super (Text2VecGoogleVectorizer .VertexBuilder .DEFAULT_BASE_URL , projectId );
132+ }
133+
134+ /** Base URL of the generative provider. */
135+ public VertexBuilder baseUrl (String baseUrl ) {
136+ super .baseUrl (baseUrl );
137+ return this ;
138+ }
139+ }
140+
113141 public static record Metadata (TokenMetadata tokens , Usage usage ) implements ProviderMetadata {
114142
115143 public static record TokenCount (Long totalBillableCharacters , Long totalTokens ) {
@@ -138,9 +166,15 @@ public static record Provider(
138166 List <String > images ,
139167 List <String > imageProperties ) implements DynamicProvider {
140168
141- public static Provider of (
142- Function <GoogleGenerative .Provider .Builder , ObjectBuilder <GoogleGenerative .Provider >> fn ) {
143- return fn .apply (new Builder ()).build ();
169+ public static Provider vertex (
170+ String projectId ,
171+ Function <GoogleGenerative .Provider .VertexBuilder , ObjectBuilder <GoogleGenerative .Provider >> fn ) {
172+ return fn .apply (new VertexBuilder (projectId )).build ();
173+ }
174+
175+ public static Provider aiStudio (
176+ Function <GoogleGenerative .Provider .AiStudioBuilder , ObjectBuilder <GoogleGenerative .Provider >> fn ) {
177+ return fn .apply (new AiStudioBuilder ()).build ();
144178 }
145179
146180 @ Override
@@ -205,24 +239,30 @@ public Provider(Builder builder) {
205239 builder .imageProperties );
206240 }
207241
208- public static class Builder implements ObjectBuilder <GoogleGenerative .Provider > {
242+ public abstract static class Builder implements ObjectBuilder <GoogleGenerative .Provider > {
243+ private final String projectId ;
209244 private String baseUrl ;
245+
210246 private Integer topK ;
211247 private Float topP ;
212248 private String model ;
213249 private Integer maxTokens ;
214250 private Float temperature ;
215251 private Float frequencyPenalty ;
216252 private Float presencePenalty ;
217- private String projectId ;
218253 private String endpointId ;
219254 private String region ;
220255 private final List <String > stopSequences = new ArrayList <>();
221256 private final List <String > images = new ArrayList <>();
222257 private final List <String > imageProperties = new ArrayList <>();
223258
259+ public Builder (String baseUrl , String projectId ) {
260+ this .projectId = projectId ;
261+ this .baseUrl = baseUrl ;
262+ }
263+
224264 /** Base URL of the generative provider. */
225- public Builder baseUrl (String baseUrl ) {
265+ protected Builder baseUrl (String baseUrl ) {
226266 this .baseUrl = baseUrl ;
227267 return this ;
228268 }
@@ -276,11 +316,6 @@ public Builder stopSequences(List<String> stopSequences) {
276316 return this ;
277317 }
278318
279- public Builder projectId (String projectId ) {
280- this .projectId = projectId ;
281- return this ;
282- }
283-
284319 public Builder endpointId (String endpointId ) {
285320 this .endpointId = endpointId ;
286321 return this ;
@@ -323,5 +358,23 @@ public GoogleGenerative.Provider build() {
323358 return new GoogleGenerative .Provider (this );
324359 }
325360 }
361+
362+ public static class AiStudioBuilder extends Builder {
363+ public AiStudioBuilder () {
364+ super (Text2VecGoogleVectorizer .AiStudioBuilder .BASE_URL , null );
365+ }
366+ }
367+
368+ public static class VertexBuilder extends Builder {
369+ public VertexBuilder (String projectId ) {
370+ super (Text2VecGoogleVectorizer .VertexBuilder .DEFAULT_BASE_URL , projectId );
371+ }
372+
373+ /** Base URL of the generative provider. */
374+ public VertexBuilder baseUrl (String baseUrl ) {
375+ super .baseUrl (baseUrl );
376+ return this ;
377+ }
378+ }
326379 }
327380}
0 commit comments