@@ -947,27 +947,23 @@ public void testInfer_Embedding_Get_Response_Ingest() throws IOException {
947947 """ ;
948948 webServer .enqueue (new MockResponse ().setResponseCode (200 ).setBody (responseJson ));
949949
950- String apiKey = "apiKey" ;
951- int dimensions = 1024 ;
952- String modelName = "jina-clip-v2" ;
953950 var model = JinaAIEmbeddingsModelTests .createModel (
954951 getUrl (webServer ),
955- apiKey ,
952+ "secret" ,
956953 JinaAIEmbeddingsTaskSettings .EMPTY_SETTINGS ,
957- 500 ,
958- dimensions ,
959- modelName ,
954+ 1024 ,
955+ 1024 ,
956+ "jina-clip-v2" ,
960957 null ,
961958 JinaAIEmbeddingType .FLOAT
962959 );
963960 PlainActionFuture <InferenceServiceResults > listener = new PlainActionFuture <>();
964- List <String > input = List .of ("abc" );
965961 service .infer (
966962 model ,
967963 null ,
968964 null ,
969965 null ,
970- input ,
966+ List . of ( "abc" ) ,
971967 false ,
972968 new HashMap <>(),
973969 InputType .INGEST ,
@@ -985,25 +981,12 @@ public void testInfer_Embedding_Get_Response_Ingest() throws IOException {
985981 webServer .requests ().get (0 ).getHeader (HttpHeaders .CONTENT_TYPE ),
986982 equalTo (XContentType .JSON .mediaType ())
987983 );
988- MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer " + apiKey ));
984+ MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer secret" ));
989985
990986 var requestMap = entityAsMap (webServer .requests ().get (0 ).getBody ());
991987 MatcherAssert .assertThat (
992988 requestMap ,
993- is (
994- Map .of (
995- "input" ,
996- input ,
997- "model" ,
998- modelName ,
999- "task" ,
1000- "retrieval.passage" ,
1001- "embedding_type" ,
1002- "float" ,
1003- "dimensions" ,
1004- dimensions
1005- )
1006- )
989+ is (Map .of ("input" , List .of ("abc" ), "model" , "jina-clip-v2" , "task" , "retrieval.passage" , "embedding_type" , "float" ))
1007990 );
1008991 }
1009992 }
@@ -1035,27 +1018,23 @@ public void testInfer_Embedding_Get_Response_Search() throws IOException {
10351018 """ ;
10361019 webServer .enqueue (new MockResponse ().setResponseCode (200 ).setBody (responseJson ));
10371020
1038- String apiKey = "apiKey" ;
1039- int dimensions = 1024 ;
1040- String modelName = "jina-clip-v2" ;
10411021 var model = JinaAIEmbeddingsModelTests .createModel (
10421022 getUrl (webServer ),
1043- apiKey ,
1023+ "secret" ,
10441024 JinaAIEmbeddingsTaskSettings .EMPTY_SETTINGS ,
1045- 500 ,
1046- dimensions ,
1047- modelName ,
1025+ 1024 ,
1026+ 1024 ,
1027+ "jina-clip-v2" ,
10481028 null ,
10491029 JinaAIEmbeddingType .FLOAT
10501030 );
10511031 PlainActionFuture <InferenceServiceResults > listener = new PlainActionFuture <>();
1052- List <String > input = List .of ("abc" );
10531032 service .infer (
10541033 model ,
10551034 null ,
10561035 null ,
10571036 null ,
1058- input ,
1037+ List . of ( "abc" ) ,
10591038 false ,
10601039 new HashMap <>(),
10611040 InputType .SEARCH ,
@@ -1073,25 +1052,12 @@ public void testInfer_Embedding_Get_Response_Search() throws IOException {
10731052 webServer .requests ().get (0 ).getHeader (HttpHeaders .CONTENT_TYPE ),
10741053 equalTo (XContentType .JSON .mediaType ())
10751054 );
1076- MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer " + apiKey ));
1055+ MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer secret" ));
10771056
10781057 var requestMap = entityAsMap (webServer .requests ().get (0 ).getBody ());
10791058 MatcherAssert .assertThat (
10801059 requestMap ,
1081- is (
1082- Map .of (
1083- "input" ,
1084- input ,
1085- "model" ,
1086- modelName ,
1087- "task" ,
1088- "retrieval.query" ,
1089- "embedding_type" ,
1090- "float" ,
1091- "dimensions" ,
1092- dimensions
1093- )
1094- )
1060+ is (Map .of ("input" , List .of ("abc" ), "model" , "jina-clip-v2" , "task" , "retrieval.query" , "embedding_type" , "float" ))
10951061 );
10961062 }
10971063 }
@@ -1107,27 +1073,23 @@ public void testInfer_Embedding_Get_Response_clustering() throws IOException {
11071073 """ ;
11081074 webServer .enqueue (new MockResponse ().setResponseCode (200 ).setBody (responseJson ));
11091075
1110- String apiKey = "apiKey" ;
1111- int dimensions = 1024 ;
1112- String modelName = "jina-clip-v2" ;
11131076 var model = JinaAIEmbeddingsModelTests .createModel (
11141077 getUrl (webServer ),
1115- apiKey ,
1078+ "secret" ,
11161079 JinaAIEmbeddingsTaskSettings .EMPTY_SETTINGS ,
1117- 500 ,
1118- dimensions ,
1119- modelName ,
1080+ 1024 ,
1081+ 1024 ,
1082+ "jina-clip-v2" ,
11201083 null ,
11211084 JinaAIEmbeddingType .FLOAT
11221085 );
11231086 PlainActionFuture <InferenceServiceResults > listener = new PlainActionFuture <>();
1124- List <String > input = List .of ("abc" );
11251087 service .infer (
11261088 model ,
11271089 null ,
11281090 null ,
11291091 null ,
1130- input ,
1092+ List . of ( "abc" ) ,
11311093 false ,
11321094 new HashMap <>(),
11331095 InputType .CLUSTERING ,
@@ -1145,12 +1107,12 @@ public void testInfer_Embedding_Get_Response_clustering() throws IOException {
11451107 webServer .requests ().get (0 ).getHeader (HttpHeaders .CONTENT_TYPE ),
11461108 equalTo (XContentType .JSON .mediaType ())
11471109 );
1148- MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer " + apiKey ));
1110+ MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer secret" ));
11491111
11501112 var requestMap = entityAsMap (webServer .requests ().get (0 ).getBody ());
11511113 MatcherAssert .assertThat (
11521114 requestMap ,
1153- is (Map .of ("input" , input , "model" , modelName , "task" , "separation" , "embedding_type" , "float" , "dimensions" , dimensions ))
1115+ is (Map .of ("input" , List . of ( "abc" ) , "model" , "jina-clip-v2" , "task" , "separation" , "embedding_type" , "float" ))
11541116 );
11551117 }
11561118 }
@@ -1182,22 +1144,29 @@ public void testInfer_Embedding_Get_Response_NullInputType() throws IOException
11821144 """ ;
11831145 webServer .enqueue (new MockResponse ().setResponseCode (200 ).setBody (responseJson ));
11841146
1185- String apiKey = "apiKey" ;
1186- int dimensions = 1024 ;
1187- String modelName = "jina-clip-v2" ;
11881147 var model = JinaAIEmbeddingsModelTests .createModel (
11891148 getUrl (webServer ),
1190- apiKey ,
1149+ "secret" ,
11911150 JinaAIEmbeddingsTaskSettings .EMPTY_SETTINGS ,
1192- 500 ,
1193- dimensions ,
1194- modelName ,
1151+ 1024 ,
1152+ 1024 ,
1153+ "jina-clip-v2" ,
11951154 null ,
11961155 JinaAIEmbeddingType .FLOAT
11971156 );
11981157 PlainActionFuture <InferenceServiceResults > listener = new PlainActionFuture <>();
1199- List <String > input = List .of ("abc" );
1200- service .infer (model , null , null , null , input , false , new HashMap <>(), null , InferenceAction .Request .DEFAULT_TIMEOUT , listener );
1158+ service .infer (
1159+ model ,
1160+ null ,
1161+ null ,
1162+ null ,
1163+ List .of ("abc" ),
1164+ false ,
1165+ new HashMap <>(),
1166+ null ,
1167+ InferenceAction .Request .DEFAULT_TIMEOUT ,
1168+ listener
1169+ );
12011170
12021171 var result = listener .actionGet (TIMEOUT );
12031172
@@ -1209,13 +1178,10 @@ public void testInfer_Embedding_Get_Response_NullInputType() throws IOException
12091178 webServer .requests ().get (0 ).getHeader (HttpHeaders .CONTENT_TYPE ),
12101179 equalTo (XContentType .JSON .mediaType ())
12111180 );
1212- MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer " + apiKey ));
1181+ MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer secret" ));
12131182
12141183 var requestMap = entityAsMap (webServer .requests ().get (0 ).getBody ());
1215- MatcherAssert .assertThat (
1216- requestMap ,
1217- is (Map .of ("input" , input , "model" , modelName , "embedding_type" , "float" , "dimensions" , dimensions ))
1218- );
1184+ MatcherAssert .assertThat (requestMap , is (Map .of ("input" , List .of ("abc" ), "model" , "jina-clip-v2" , "embedding_type" , "float" )));
12191185 }
12201186 }
12211187
@@ -1598,27 +1564,23 @@ public void testInfer_Embedding_DoesNotSetInputType_WhenNotPresentInTaskSettings
15981564 """ ;
15991565 webServer .enqueue (new MockResponse ().setResponseCode (200 ).setBody (responseJson ));
16001566
1601- String apiKey = "apiKey" ;
1602- int dimensions = 1024 ;
1603- String modelName = "jina-clip-v2" ;
16041567 var model = JinaAIEmbeddingsModelTests .createModel (
16051568 getUrl (webServer ),
1606- apiKey ,
1569+ "secret" ,
16071570 new JinaAIEmbeddingsTaskSettings ((InputType ) null ),
1608- 500 ,
1609- dimensions ,
1610- modelName ,
1571+ 1024 ,
1572+ 1024 ,
1573+ "jina-clip-v2" ,
16111574 null ,
16121575 JinaAIEmbeddingType .FLOAT
16131576 );
16141577 PlainActionFuture <InferenceServiceResults > listener = new PlainActionFuture <>();
1615- List <String > input = List .of ("abc" );
16161578 service .infer (
16171579 model ,
16181580 null ,
16191581 null ,
16201582 null ,
1621- input ,
1583+ List . of ( "abc" ) ,
16221584 false ,
16231585 new HashMap <>(),
16241586 InputType .UNSPECIFIED ,
@@ -1635,13 +1597,10 @@ public void testInfer_Embedding_DoesNotSetInputType_WhenNotPresentInTaskSettings
16351597 webServer .requests ().get (0 ).getHeader (HttpHeaders .CONTENT_TYPE ),
16361598 equalTo (XContentType .JSON .mediaType ())
16371599 );
1638- MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer " + apiKey ));
1600+ MatcherAssert .assertThat (webServer .requests ().get (0 ).getHeader (HttpHeaders .AUTHORIZATION ), equalTo ("Bearer secret" ));
16391601
16401602 var requestMap = entityAsMap (webServer .requests ().get (0 ).getBody ());
1641- MatcherAssert .assertThat (
1642- requestMap ,
1643- is (Map .of ("input" , input , "model" , modelName , "embedding_type" , "float" , "dimensions" , dimensions ))
1644- );
1603+ MatcherAssert .assertThat (requestMap , is (Map .of ("input" , List .of ("abc" ), "model" , "jina-clip-v2" , "embedding_type" , "float" )));
16451604 }
16461605 }
16471606
0 commit comments