@@ -714,121 +714,6 @@ public void testCohereGenerateTextModel() throws IOException, InterruptedExcepti
714
714
assertFalse (((String ) responseMap .get ("text" )).isEmpty ());
715
715
}
716
716
717
- @ Ignore
718
- public void testCohereClassifyModel () throws IOException , InterruptedException {
719
- // Skip test if key is null
720
- if (COHERE_KEY == null ) {
721
- return ;
722
- }
723
- String entity = "{\n "
724
- + " \" name\" : \" Cohere classify model Connector\" ,\n "
725
- + " \" description\" : \" The connector to public Cohere classify model service\" ,\n "
726
- + " \" version\" : 1,\n "
727
- + " \" client_config\" : {\n "
728
- + " \" max_connection\" : 20,\n "
729
- + " \" connection_timeout\" : 50000,\n "
730
- + " \" read_timeout\" : 50000\n "
731
- + " },\n "
732
- + " \" protocol\" : \" http\" ,\n "
733
- + " \" parameters\" : {\n "
734
- + " \" endpoint\" : \" api.cohere.ai\" ,\n "
735
- + " \" auth\" : \" API_Key\" ,\n "
736
- + " \" content_type\" : \" application/json\" ,\n "
737
- + " \" max_tokens\" : \" 20\" \n "
738
- + " },\n "
739
- + " \" credential\" : {\n "
740
- + " \" cohere_key\" : \" "
741
- + COHERE_KEY
742
- + "\" \n "
743
- + " },\n "
744
- + " \" actions\" : [\n "
745
- + " {\n "
746
- + " \" action_type\" : \" predict\" ,\n "
747
- + " \" method\" : \" POST\" ,\n "
748
- + " \" url\" : \" https://${parameters.endpoint}/v1/classify\" ,\n "
749
- + " \" headers\" : { \n "
750
- + " \" Authorization\" : \" Bearer ${credential.cohere_key}\" \n "
751
- + " },\n "
752
- + " \" request_body\" : \" { \\ \" inputs\\ \" : ${parameters.inputs}, \\ \" examples\\ \" : ${parameters.examples}, \\ \" truncate\\ \" : \\ \" END\\ \" }\" \n "
753
- + " }\n "
754
- + " ]\n "
755
- + "}" ;
756
- Response response = createConnector (entity );
757
- Map responseMap = parseResponseToMap (response );
758
- String connectorId = (String ) responseMap .get ("connector_id" );
759
- response = registerRemoteModel ("cohere classify model" , connectorId );
760
- responseMap = parseResponseToMap (response );
761
- String taskId = (String ) responseMap .get ("task_id" );
762
- waitForTask (taskId , MLTaskState .COMPLETED );
763
- response = getTask (taskId );
764
- responseMap = parseResponseToMap (response );
765
- String modelId = (String ) responseMap .get ("model_id" );
766
- response = deployRemoteModel (modelId );
767
- responseMap = parseResponseToMap (response );
768
- taskId = (String ) responseMap .get ("task_id" );
769
- waitForTask (taskId , MLTaskState .COMPLETED );
770
- String predictInput = "{\n "
771
- + " \" parameters\" : {\n "
772
- + " \" inputs\" : [\n "
773
- + " \" Confirm your email address\" ,\n "
774
- + " \" hey i need u to send some $\" \n "
775
- + " ],\n "
776
- + " \" examples\" : [\n "
777
- + " {\n "
778
- + " \" text\" : \" Dermatologists don't like her!\" ,\n "
779
- + " \" label\" : \" Spam\" \n "
780
- + " },\n "
781
- + " {\n "
782
- + " \" text\" : \" Hello, open to this?\" ,\n "
783
- + " \" label\" : \" Spam\" \n "
784
- + " },\n "
785
- + " {\n "
786
- + " \" text\" : \" I need help please wire me $1000 right now\" ,\n "
787
- + " \" label\" : \" Spam\" \n "
788
- + " },\n "
789
- + " {\n "
790
- + " \" text\" : \" Nice to know you ;)\" ,\n "
791
- + " \" label\" : \" Spam\" \n "
792
- + " },\n "
793
- + " {\n "
794
- + " \" text\" : \" Please help me?\" ,\n "
795
- + " \" label\" : \" Spam\" \n "
796
- + " },\n "
797
- + " {\n "
798
- + " \" text\" : \" Your parcel will be delivered today\" ,\n "
799
- + " \" label\" : \" Not spam\" \n "
800
- + " },\n "
801
- + " {\n "
802
- + " \" text\" : \" Review changes to our Terms and Conditions\" ,\n "
803
- + " \" label\" : \" Not spam\" \n "
804
- + " },\n "
805
- + " {\n "
806
- + " \" text\" : \" Weekly sync notes\" ,\n "
807
- + " \" label\" : \" Not spam\" \n "
808
- + " },\n "
809
- + " {\n "
810
- + " \" text\" : \" Re: Follow up from todays meeting\" ,\n "
811
- + " \" label\" : \" Not spam\" \n "
812
- + " },\n "
813
- + " {\n "
814
- + " \" text\" : \" Pre-read for tomorrow\" ,\n "
815
- + " \" label\" : \" Not spam\" \n "
816
- + " }\n "
817
- + " ]\n "
818
- + " }\n "
819
- + "}" ;
820
-
821
- response = predictRemoteModel (modelId , predictInput );
822
- responseMap = parseResponseToMap (response );
823
- List responseList = (List ) responseMap .get ("inference_results" );
824
- responseMap = (Map ) responseList .get (0 );
825
- responseList = (List ) responseMap .get ("output" );
826
- responseMap = (Map ) responseList .get (0 );
827
- responseMap = (Map ) responseMap .get ("dataAsMap" );
828
- responseList = (List ) responseMap .get ("classifications" );
829
- assertFalse (responseList .isEmpty ());
830
- }
831
-
832
717
public static Response createConnector (String input ) throws IOException {
833
718
return TestHelper .makeRequest (client (), "POST" , "/_plugins/_ml/connectors/_create" , null , TestHelper .toHttpEntity (input ), null );
834
719
}
0 commit comments