15
15
import org .elasticsearch .core .Nullable ;
16
16
import org .elasticsearch .inference .ModelConfigurations ;
17
17
import org .elasticsearch .inference .ServiceSettings ;
18
- import org .elasticsearch .inference .SimilarityMeasure ;
19
18
import org .elasticsearch .xcontent .ToXContentObject ;
20
19
import org .elasticsearch .xcontent .XContentBuilder ;
21
20
import org .elasticsearch .xpack .inference .services .ConfigurationParseContext ;
28
27
import java .util .Objects ;
29
28
import java .util .Set ;
30
29
31
- import static org .elasticsearch .xpack .inference .services .ServiceFields .DIMENSIONS ;
32
- import static org .elasticsearch .xpack .inference .services .ServiceFields .MAX_INPUT_TOKENS ;
33
- import static org .elasticsearch .xpack .inference .services .ServiceFields .SIMILARITY ;
34
30
import static org .elasticsearch .xpack .inference .services .ServiceFields .URL ;
35
31
import static org .elasticsearch .xpack .inference .services .ServiceUtils .convertToUri ;
36
32
import static org .elasticsearch .xpack .inference .services .ServiceUtils .createOptionalUri ;
37
33
import static org .elasticsearch .xpack .inference .services .ServiceUtils .extractOptionalString ;
38
34
import static org .elasticsearch .xpack .inference .services .ServiceUtils .extractRequiredString ;
39
- import static org .elasticsearch .xpack .inference .services .ServiceUtils .extractSimilarity ;
40
- import static org .elasticsearch .xpack .inference .services .ServiceUtils .removeAsType ;
41
35
42
36
public class AlibabaCloudSearchServiceSettings extends FilteredXContentObject
43
37
implements
@@ -57,9 +51,6 @@ public static AlibabaCloudSearchServiceSettings fromMap(Map<String, Object> map,
57
51
58
52
String url = extractOptionalString (map , URL , ModelConfigurations .SERVICE_SETTINGS , validationException );
59
53
60
- SimilarityMeasure similarity = extractSimilarity (map , ModelConfigurations .SERVICE_SETTINGS , validationException );
61
- Integer dims = removeAsType (map , DIMENSIONS , Integer .class );
62
- Integer maxInputTokens = removeAsType (map , MAX_INPUT_TOKENS , Integer .class );
63
54
URI uri = convertToUri (url , URL , ModelConfigurations .SERVICE_SETTINGS , validationException );
64
55
String modelId = extractRequiredString (map , MODEL_ID , ModelConfigurations .SERVICE_SETTINGS , validationException );
65
56
String host = extractRequiredString (map , HOST , ModelConfigurations .SERVICE_SETTINGS , validationException );
@@ -85,23 +76,10 @@ public static AlibabaCloudSearchServiceSettings fromMap(Map<String, Object> map,
85
76
throw validationException ;
86
77
}
87
78
88
- return new AlibabaCloudSearchServiceSettings (
89
- uri ,
90
- similarity ,
91
- dims ,
92
- maxInputTokens ,
93
- modelId ,
94
- host ,
95
- workspaceName ,
96
- httpSchema ,
97
- rateLimitSettings
98
- );
79
+ return new AlibabaCloudSearchServiceSettings (uri , modelId , host , workspaceName , httpSchema , rateLimitSettings );
99
80
}
100
81
101
82
private final URI uri ;
102
- private final SimilarityMeasure similarity ;
103
- private final Integer dimensions ;
104
- private final Integer maxInputTokens ;
105
83
private final String modelId ;
106
84
private final String host ;
107
85
private final String workspaceName ;
@@ -110,19 +88,13 @@ public static AlibabaCloudSearchServiceSettings fromMap(Map<String, Object> map,
110
88
111
89
public AlibabaCloudSearchServiceSettings (
112
90
@ Nullable URI uri ,
113
- @ Nullable SimilarityMeasure similarity ,
114
- @ Nullable Integer dimensions ,
115
- @ Nullable Integer maxInputTokens ,
116
91
String modelId ,
117
92
String host ,
118
93
String workspaceName ,
119
94
@ Nullable String httpSchema ,
120
95
@ Nullable RateLimitSettings rateLimitSettings
121
96
) {
122
97
this .uri = uri ;
123
- this .similarity = similarity ;
124
- this .dimensions = dimensions ;
125
- this .maxInputTokens = maxInputTokens ;
126
98
this .modelId = modelId ;
127
99
this .host = host ;
128
100
this .workspaceName = workspaceName ;
@@ -132,9 +104,6 @@ public AlibabaCloudSearchServiceSettings(
132
104
133
105
public AlibabaCloudSearchServiceSettings (StreamInput in ) throws IOException {
134
106
uri = createOptionalUri (in .readOptionalString ());
135
- similarity = in .readOptionalEnum (SimilarityMeasure .class );
136
- dimensions = in .readOptionalVInt ();
137
- maxInputTokens = in .readOptionalVInt ();
138
107
modelId = in .readString ();
139
108
host = in .readString ();
140
109
workspaceName = in .readString ();
@@ -146,18 +115,6 @@ public URI getUri() {
146
115
return uri ;
147
116
}
148
117
149
- public SimilarityMeasure getSimilarity () {
150
- return similarity ;
151
- }
152
-
153
- public Integer getDimensions () {
154
- return dimensions ;
155
- }
156
-
157
- public Integer getMaxInputTokens () {
158
- return maxInputTokens ;
159
- }
160
-
161
118
@ Override
162
119
public String modelId () {
163
120
return modelId ;
@@ -204,15 +161,6 @@ public XContentBuilder toXContentFragmentOfExposedFields(XContentBuilder builder
204
161
if (uri != null ) {
205
162
builder .field (URL , uri .toString ());
206
163
}
207
- if (similarity != null ) {
208
- builder .field (SIMILARITY , similarity );
209
- }
210
- if (dimensions != null ) {
211
- builder .field (DIMENSIONS , dimensions );
212
- }
213
- if (maxInputTokens != null ) {
214
- builder .field (MAX_INPUT_TOKENS , maxInputTokens );
215
- }
216
164
if (modelId != null ) {
217
165
builder .field (MODEL_ID , modelId );
218
166
}
@@ -240,9 +188,6 @@ public TransportVersion getMinimalSupportedVersion() {
240
188
public void writeTo (StreamOutput out ) throws IOException {
241
189
var uriToWrite = uri != null ? uri .toString () : null ;
242
190
out .writeOptionalString (uriToWrite );
243
- out .writeOptionalEnum (similarity );
244
- out .writeOptionalVInt (dimensions );
245
- out .writeOptionalVInt (maxInputTokens );
246
191
out .writeString (modelId );
247
192
out .writeString (host );
248
193
out .writeString (workspaceName );
@@ -256,9 +201,6 @@ public boolean equals(Object o) {
256
201
if (o == null || getClass () != o .getClass ()) return false ;
257
202
AlibabaCloudSearchServiceSettings that = (AlibabaCloudSearchServiceSettings ) o ;
258
203
return Objects .equals (uri , that .uri )
259
- && Objects .equals (similarity , that .similarity )
260
- && Objects .equals (dimensions , that .dimensions )
261
- && Objects .equals (maxInputTokens , that .maxInputTokens )
262
204
&& Objects .equals (modelId , that .modelId )
263
205
&& Objects .equals (host , that .host )
264
206
&& Objects .equals (workspaceName , that .workspaceName )
@@ -267,6 +209,6 @@ public boolean equals(Object o) {
267
209
268
210
@ Override
269
211
public int hashCode () {
270
- return Objects .hash (uri , similarity , dimensions , maxInputTokens , modelId , host , workspaceName , httpSchema );
212
+ return Objects .hash (uri , modelId , host , workspaceName , httpSchema );
271
213
}
272
214
}
0 commit comments