Skip to content

Commit f8f7bdf

Browse files
committed
feat: add configurations for generative modules:
- Mistral - Anyscale - Databricks
1 parent dde9e11 commit f8f7bdf

4 files changed

Lines changed: 228 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@
1313
import com.google.gson.stream.JsonToken;
1414
import com.google.gson.stream.JsonWriter;
1515

16+
import io.weaviate.client6.v1.api.collections.generative.AnyscaleGenerative;
1617
import io.weaviate.client6.v1.api.collections.generative.CohereGenerative;
18+
import io.weaviate.client6.v1.api.collections.generative.DatabricksGenerative;
1719
import io.weaviate.client6.v1.api.collections.generative.DummyGenerative;
20+
import io.weaviate.client6.v1.api.collections.generative.MistralGenerative;
1821
import io.weaviate.client6.v1.internal.ObjectBuilder;
1922
import io.weaviate.client6.v1.internal.json.JsonEnum;
2023

2124
public interface Generative {
2225
public enum Kind implements JsonEnum<Kind> {
26+
ANYSCALE("generative-anyscale"),
2327
COHERE("generative-cohere"),
28+
DATABRICKS("generative-databricks"),
29+
MISTRAL("generative-mistral"),
2430
DUMMY("generative-dummy");
2531

2632
private static final Map<String, Kind> jsonValueMap = JsonEnum.collectNames(Kind.values());
@@ -69,7 +75,10 @@ private final void addAdapter(Gson gson, Generative.Kind kind, Class<? extends G
6975
}
7076

7177
private final void init(Gson gson) {
78+
addAdapter(gson, Generative.Kind.ANYSCALE, AnyscaleGenerative.class);
7279
addAdapter(gson, Generative.Kind.COHERE, CohereGenerative.class);
80+
addAdapter(gson, Generative.Kind.DATABRICKS, DatabricksGenerative.class);
81+
addAdapter(gson, Generative.Kind.MISTRAL, MistralGenerative.class);
7382
addAdapter(gson, Generative.Kind.DUMMY, DummyGenerative.class);
7483
}
7584

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package io.weaviate.client6.v1.api.collections.generative;
2+
3+
import java.util.function.Function;
4+
5+
import com.google.gson.annotations.SerializedName;
6+
7+
import io.weaviate.client6.v1.api.collections.Generative;
8+
import io.weaviate.client6.v1.internal.ObjectBuilder;
9+
10+
public record AnyscaleGenerative(
11+
@SerializedName("baseURL") String baseUrl,
12+
@SerializedName("model") String model,
13+
@SerializedName("temperature") Float temperature) implements Generative {
14+
15+
@Override
16+
public Kind _kind() {
17+
return Generative.Kind.ANYSCALE;
18+
}
19+
20+
@Override
21+
public Object _self() {
22+
return this;
23+
}
24+
25+
public static AnyscaleGenerative of() {
26+
return of(ObjectBuilder.identity());
27+
}
28+
29+
public static AnyscaleGenerative of(Function<Builder, ObjectBuilder<AnyscaleGenerative>> fn) {
30+
return fn.apply(new Builder()).build();
31+
}
32+
33+
public AnyscaleGenerative(Builder builder) {
34+
this(
35+
builder.baseUrl,
36+
builder.model,
37+
builder.temperature);
38+
}
39+
40+
public static class Builder implements ObjectBuilder<AnyscaleGenerative> {
41+
private String baseUrl;
42+
private String model;
43+
private Float temperature;
44+
45+
public Builder baseUrl(String baseUrl) {
46+
this.baseUrl = baseUrl;
47+
return this;
48+
}
49+
50+
public Builder model(String model) {
51+
this.model = model;
52+
return this;
53+
}
54+
55+
public Builder temperature(float temperature) {
56+
this.temperature = temperature;
57+
return this;
58+
}
59+
60+
@Override
61+
public AnyscaleGenerative build() {
62+
return new AnyscaleGenerative(this);
63+
}
64+
}
65+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package io.weaviate.client6.v1.api.collections.generative;
2+
3+
import java.util.function.Function;
4+
5+
import com.google.gson.annotations.SerializedName;
6+
7+
import io.weaviate.client6.v1.api.collections.Generative;
8+
import io.weaviate.client6.v1.internal.ObjectBuilder;
9+
10+
public record DatabricksGenerative(
11+
@SerializedName("endpoint") String baseUrl,
12+
@SerializedName("maxTokens") Integer maxTokens,
13+
@SerializedName("topK") Integer topK,
14+
@SerializedName("topP") Float topP,
15+
@SerializedName("temperature") Float temperature) implements Generative {
16+
17+
@Override
18+
public Kind _kind() {
19+
return Generative.Kind.DATABRICKS;
20+
}
21+
22+
@Override
23+
public Object _self() {
24+
return this;
25+
}
26+
27+
public static DatabricksGenerative of() {
28+
return of(ObjectBuilder.identity());
29+
}
30+
31+
public static DatabricksGenerative of(Function<Builder, ObjectBuilder<DatabricksGenerative>> fn) {
32+
return fn.apply(new Builder()).build();
33+
}
34+
35+
public DatabricksGenerative(Builder builder) {
36+
this(
37+
builder.endpoint,
38+
builder.maxTokens,
39+
builder.topK,
40+
builder.topP,
41+
builder.temperature);
42+
}
43+
44+
public static class Builder implements ObjectBuilder<DatabricksGenerative> {
45+
private String endpoint;
46+
private Integer maxTokens;
47+
private Integer topK;
48+
private Float topP;
49+
private Float temperature;
50+
51+
public Builder endpoint(String endpoint) {
52+
this.endpoint = endpoint;
53+
return this;
54+
}
55+
56+
public Builder maxTokens(int maxTokens) {
57+
this.maxTokens = maxTokens;
58+
return this;
59+
}
60+
61+
public Builder topK(int topK) {
62+
this.topK = topK;
63+
return this;
64+
}
65+
66+
public Builder topP(float topP) {
67+
this.topP = topP;
68+
return this;
69+
}
70+
71+
public Builder temperature(float temperature) {
72+
this.temperature = temperature;
73+
return this;
74+
}
75+
76+
@Override
77+
public DatabricksGenerative build() {
78+
return new DatabricksGenerative(this);
79+
}
80+
}
81+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package io.weaviate.client6.v1.api.collections.generative;
2+
3+
import java.util.function.Function;
4+
5+
import com.google.gson.annotations.SerializedName;
6+
7+
import io.weaviate.client6.v1.api.collections.Generative;
8+
import io.weaviate.client6.v1.internal.ObjectBuilder;
9+
10+
public record MistralGenerative(
11+
@SerializedName("baseURL") String baseUrl,
12+
@SerializedName("model") String model,
13+
@SerializedName("maxTokens") Integer maxTokens,
14+
@SerializedName("temperature") Float temperature) implements Generative {
15+
16+
@Override
17+
public Kind _kind() {
18+
return Generative.Kind.MISTRAL;
19+
}
20+
21+
@Override
22+
public Object _self() {
23+
return this;
24+
}
25+
26+
public static MistralGenerative of() {
27+
return of(ObjectBuilder.identity());
28+
}
29+
30+
public static MistralGenerative of(Function<Builder, ObjectBuilder<MistralGenerative>> fn) {
31+
return fn.apply(new Builder()).build();
32+
}
33+
34+
public MistralGenerative(Builder builder) {
35+
this(
36+
builder.baseUrl,
37+
builder.model,
38+
builder.maxTokens,
39+
builder.temperature);
40+
}
41+
42+
public static class Builder implements ObjectBuilder<MistralGenerative> {
43+
private String baseUrl;
44+
private String model;
45+
private Integer maxTokens;
46+
private Float temperature;
47+
48+
public Builder baseUrl(String baseUrl) {
49+
this.baseUrl = baseUrl;
50+
return this;
51+
}
52+
53+
public Builder maxTokens(int maxTokens) {
54+
this.maxTokens = maxTokens;
55+
return this;
56+
}
57+
58+
public Builder model(String model) {
59+
this.model = model;
60+
return this;
61+
}
62+
63+
public Builder temperature(float temperature) {
64+
this.temperature = temperature;
65+
return this;
66+
}
67+
68+
@Override
69+
public MistralGenerative build() {
70+
return new MistralGenerative(this);
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)