@@ -1045,6 +1045,79 @@ describe.skip("InferenceClient", () => {
1045
1045
TIMEOUT
1046
1046
) ;
1047
1047
1048
+ describe . concurrent (
1049
+ "Featherless" ,
1050
+ ( ) => {
1051
+ HARDCODED_MODEL_INFERENCE_MAPPING [ "featherless-ai" ] = {
1052
+ "meta-llama/Llama-3.1-8B" : {
1053
+ providerId : "meta-llama/Meta-Llama-3.1-8B" ,
1054
+ hfModelId : "meta-llama/Llama-3.1-8B" ,
1055
+ task : "text-generation" ,
1056
+ status : "live" ,
1057
+ } ,
1058
+ "meta-llama/Llama-3.1-8B-Instruct" : {
1059
+ providerId : "meta-llama/Meta-Llama-3.1-8B-Instruct" ,
1060
+ hfModelId : "meta-llama/Llama-3.1-8B-Instruct" ,
1061
+ task : "text-generation" ,
1062
+ status : "live" ,
1063
+ } ,
1064
+ } ;
1065
+
1066
+ it ( "chatCompletion" , async ( ) => {
1067
+ const res = await chatCompletion ( {
1068
+ accessToken : env . HF_FEATHERLESS_KEY ?? "dummy" ,
1069
+ model : "meta-llama/Llama-3.1-8B-Instruct" ,
1070
+ provider : "featherless-ai" ,
1071
+ messages : [ { role : "user" , content : "Complete this sentence with words, one plus one is equal " } ] ,
1072
+ temperature : 0.1 ,
1073
+ } ) ;
1074
+
1075
+ expect ( res ) . toBeDefined ( ) ;
1076
+ expect ( res . choices ) . toBeDefined ( ) ;
1077
+ expect ( res . choices ?. length ) . toBeGreaterThan ( 0 ) ;
1078
+
1079
+ if ( res . choices && res . choices . length > 0 ) {
1080
+ const completion = res . choices [ 0 ] . message ?. content ;
1081
+ expect ( completion ) . toBeDefined ( ) ;
1082
+ expect ( typeof completion ) . toBe ( "string" ) ;
1083
+ expect ( completion ) . toContain ( "two" ) ;
1084
+ }
1085
+ } ) ;
1086
+
1087
+ it ( "chatCompletion stream" , async ( ) => {
1088
+ const stream = chatCompletionStream ( {
1089
+ accessToken : env . HF_FEATHERLESS_KEY ?? "dummy" ,
1090
+ model : "meta-llama/Llama-3.1-8B-Instruct" ,
1091
+ provider : "featherless-ai" ,
1092
+ messages : [ { role : "user" , content : "Complete the equation 1 + 1 = , just the answer" } ] ,
1093
+ } ) as AsyncGenerator < ChatCompletionStreamOutput > ;
1094
+ let out = "" ;
1095
+ for await ( const chunk of stream ) {
1096
+ if ( chunk . choices && chunk . choices . length > 0 ) {
1097
+ out += chunk . choices [ 0 ] . delta . content ;
1098
+ }
1099
+ }
1100
+ expect ( out ) . toContain ( "2" ) ;
1101
+ } ) ;
1102
+
1103
+ it ( "textGeneration" , async ( ) => {
1104
+ const res = await textGeneration ( {
1105
+ accessToken : env . HF_FEATHERLESS_KEY ?? "dummy" ,
1106
+ model : "meta-llama/Llama-3.1-8B" ,
1107
+ provider : "featherless-ai" ,
1108
+ inputs : "Paris is a city of " ,
1109
+ parameters : {
1110
+ temperature : 0 ,
1111
+ top_p : 0.01 ,
1112
+ max_tokens : 10 ,
1113
+ } ,
1114
+ } ) ;
1115
+ expect ( res ) . toMatchObject ( { generated_text : "2.2 million people, and it is the" } ) ;
1116
+ } ) ;
1117
+ } ,
1118
+ TIMEOUT
1119
+ ) ;
1120
+
1048
1121
describe . concurrent (
1049
1122
"Replicate" ,
1050
1123
( ) => {
0 commit comments