Skip to content

Commit f26b55d

Browse files
committed
feat: extend generative functionality to async client
1 parent af31af4 commit f26b55d

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/main/java/io/weaviate/client6/v1/api/collections/CollectionHandleAsync.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import io.weaviate.client6.v1.api.collections.aggregate.WeaviateAggregateClientAsync;
99
import io.weaviate.client6.v1.api.collections.config.WeaviateConfigClientAsync;
1010
import io.weaviate.client6.v1.api.collections.data.WeaviateDataClientAsync;
11+
import io.weaviate.client6.v1.api.collections.generate.WeaviateGenerateClientAsync;
1112
import io.weaviate.client6.v1.api.collections.pagination.AsyncPaginator;
1213
import io.weaviate.client6.v1.api.collections.query.ConsistencyLevel;
1314
import io.weaviate.client6.v1.api.collections.query.WeaviateQueryClientAsync;
@@ -21,6 +22,7 @@ public class CollectionHandleAsync<PropertiesT> {
2122
public final WeaviateConfigClientAsync config;
2223
public final WeaviateDataClientAsync<PropertiesT> data;
2324
public final WeaviateQueryClientAsync<PropertiesT> query;
25+
public final WeaviateGenerateClientAsync<PropertiesT> generate;
2426
public final WeaviateAggregateClientAsync aggregate;
2527
public final WeaviateTenantsClientAsync tenants;
2628

@@ -35,6 +37,7 @@ public CollectionHandleAsync(
3537
this.config = new WeaviateConfigClientAsync(collection, restTransport, grpcTransport, defaults);
3638
this.aggregate = new WeaviateAggregateClientAsync(collection, grpcTransport, defaults);
3739
this.query = new WeaviateQueryClientAsync<>(collection, grpcTransport, defaults);
40+
this.generate = new WeaviateGenerateClientAsync<>(collection, grpcTransport, defaults);
3841
this.data = new WeaviateDataClientAsync<>(collection, restTransport, grpcTransport, defaults);
3942
this.defaults = defaults;
4043

@@ -46,6 +49,7 @@ private CollectionHandleAsync(CollectionHandleAsync<PropertiesT> c, CollectionHa
4649
this.config = new WeaviateConfigClientAsync(c.config, defaults);
4750
this.aggregate = new WeaviateAggregateClientAsync(c.aggregate, defaults);
4851
this.query = new WeaviateQueryClientAsync<>(c.query, defaults);
52+
this.generate = new WeaviateGenerateClientAsync<>(c.generate, defaults);
4953
this.data = new WeaviateDataClientAsync<>(c.data, defaults);
5054
this.defaults = defaults;
5155

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package io.weaviate.client6.v1.api.collections.generate;
2+
3+
import java.util.concurrent.CompletableFuture;
4+
5+
import io.weaviate.client6.v1.api.collections.CollectionHandleDefaults;
6+
import io.weaviate.client6.v1.api.collections.query.GroupBy;
7+
import io.weaviate.client6.v1.api.collections.query.QueryOperator;
8+
import io.weaviate.client6.v1.internal.grpc.GrpcTransport;
9+
import io.weaviate.client6.v1.internal.orm.CollectionDescriptor;
10+
11+
public class WeaviateGenerateClientAsync<PropertiesT>
12+
extends
13+
AbstractGenerateClient<PropertiesT, CompletableFuture<GenerativeResponse<PropertiesT>>, CompletableFuture<GenerativeResponseGrouped<PropertiesT>>> {
14+
15+
public WeaviateGenerateClientAsync(
16+
CollectionDescriptor<PropertiesT> collection,
17+
GrpcTransport grpcTransport,
18+
CollectionHandleDefaults defaults) {
19+
super(collection, grpcTransport, defaults);
20+
}
21+
22+
/** Copy constructor that sets new defaults. */
23+
public WeaviateGenerateClientAsync(WeaviateGenerateClientAsync<PropertiesT> c, CollectionHandleDefaults defaults) {
24+
super(c, defaults);
25+
}
26+
27+
@Override
28+
protected final CompletableFuture<GenerativeResponse<PropertiesT>> performRequest(QueryOperator operator,
29+
GenerativeTask generate) {
30+
var request = new GenerativeRequest(operator, generate, null);
31+
return this.grpcTransport.performRequestAsync(request, GenerativeRequest.rpc(collection, defaults));
32+
}
33+
34+
@Override
35+
protected final CompletableFuture<GenerativeResponseGrouped<PropertiesT>> performRequest(QueryOperator operator,
36+
GenerativeTask generate,
37+
GroupBy groupBy) {
38+
var request = new GenerativeRequest(operator, generate, groupBy);
39+
return this.grpcTransport.performRequestAsync(request, GenerativeRequest.grouped(collection, defaults));
40+
}
41+
}

0 commit comments

Comments
 (0)