|
50 | 50 | import org.elasticsearch.xpack.inference.services.ServiceFields; |
51 | 51 | import org.elasticsearch.xpack.inference.services.ibmwatsonx.embeddings.IbmWatsonxEmbeddingsModel; |
52 | 52 | import org.elasticsearch.xpack.inference.services.ibmwatsonx.embeddings.IbmWatsonxEmbeddingsModelTests; |
| 53 | +import org.elasticsearch.xpack.inference.services.ibmwatsonx.rerank.IbmWatsonxRerankModel; |
53 | 54 | import org.elasticsearch.xpack.inference.services.openai.completion.OpenAiChatCompletionModelTests; |
54 | 55 | import org.hamcrest.MatcherAssert; |
55 | 56 | import org.hamcrest.Matchers; |
@@ -154,6 +155,42 @@ public void testParseRequestConfig_CreatesAIbmWatsonxEmbeddingsModel() throws IO |
154 | 155 | } |
155 | 156 | } |
156 | 157 |
|
| 158 | + public void testParseRequestConfig_CreatesAIbmWatsonxRerankModel() throws IOException { |
| 159 | + try (var service = createIbmWatsonxService()) { |
| 160 | + ActionListener<Model> modelListener = ActionListener.wrap(model -> { |
| 161 | + assertThat(model, instanceOf(IbmWatsonxRerankModel.class)); |
| 162 | + |
| 163 | + var rerankModel = (IbmWatsonxRerankModel) model; |
| 164 | + assertThat(rerankModel.getServiceSettings().modelId(), is(modelId)); |
| 165 | + assertThat(rerankModel.getServiceSettings().projectId(), is(projectId)); |
| 166 | + assertThat(rerankModel.getServiceSettings().apiVersion(), is(apiVersion)); |
| 167 | + assertThat(rerankModel.getSecretSettings().apiKey().toString(), is(apiKey)); |
| 168 | + }, e -> fail("Model parsing should have succeeded, but failed: " + e.getMessage())); |
| 169 | + |
| 170 | + service.parseRequestConfig( |
| 171 | + "id", |
| 172 | + TaskType.RERANK, |
| 173 | + getRequestConfigMap( |
| 174 | + new HashMap<>( |
| 175 | + Map.of( |
| 176 | + ServiceFields.MODEL_ID, |
| 177 | + modelId, |
| 178 | + IbmWatsonxServiceFields.PROJECT_ID, |
| 179 | + projectId, |
| 180 | + ServiceFields.URL, |
| 181 | + url, |
| 182 | + IbmWatsonxServiceFields.API_VERSION, |
| 183 | + apiVersion |
| 184 | + ) |
| 185 | + ), |
| 186 | + new HashMap<>(Map.of()), |
| 187 | + getSecretSettingsMap(apiKey) |
| 188 | + ), |
| 189 | + modelListener |
| 190 | + ); |
| 191 | + } |
| 192 | + } |
| 193 | + |
157 | 194 | public void testParseRequestConfig_CreatesAIbmWatsonxEmbeddingsModelWhenChunkingSettingsProvided() throws IOException { |
158 | 195 | try (var service = createIbmWatsonxService()) { |
159 | 196 | ActionListener<Model> modelListener = ActionListener.wrap(model -> { |
|
0 commit comments