@@ -1175,4 +1175,69 @@ describe.concurrent("HfInference", () => {
11751175 } ,
11761176 TIMEOUT
11771177 ) ;
1178+
1179+ describe . concurrent (
1180+ "Hyperbolic" ,
1181+ ( ) => {
1182+ const client = new HfInference ( env . HF_HYPERBOLIC_KEY ) ;
1183+
1184+ it ( "chatCompletion - hyperbolic" , async ( ) => {
1185+ const res = await client . chatCompletion ( {
1186+ model : "meta-llama/Llama-3.2-3B-Instruct" ,
1187+ provider : "hyperbolic" ,
1188+ messages : [ { role : "user" , content : "Complete this sentence with words, one plus one is equal " } ] ,
1189+ temperature : 0.1 ,
1190+ } ) ;
1191+
1192+ expect ( res ) . toBeDefined ( ) ;
1193+ expect ( res . choices ) . toBeDefined ( ) ;
1194+ expect ( res . choices ?. length ) . toBeGreaterThan ( 0 ) ;
1195+
1196+ if ( res . choices && res . choices . length > 0 ) {
1197+ const completion = res . choices [ 0 ] . message ?. content ;
1198+ expect ( completion ) . toBeDefined ( ) ;
1199+ expect ( typeof completion ) . toBe ( "string" ) ;
1200+ expect ( completion ) . toContain ( "two" ) ;
1201+ }
1202+ } ) ;
1203+
1204+ it ( "chatCompletion stream" , async ( ) => {
1205+ const stream = client . chatCompletionStream ( {
1206+ model : "meta-llama/Llama-3.3-70B-Instruct" ,
1207+ provider : "hyperbolic" ,
1208+ messages : [ { role : "user" , content : "Complete the equation 1 + 1 = , just the answer" } ] ,
1209+ } ) as AsyncGenerator < ChatCompletionStreamOutput > ;
1210+ let out = "" ;
1211+ for await ( const chunk of stream ) {
1212+ if ( chunk . choices && chunk . choices . length > 0 ) {
1213+ out += chunk . choices [ 0 ] . delta . content ;
1214+ }
1215+ }
1216+ expect ( out ) . toContain ( "2" ) ;
1217+ } ) ;
1218+
1219+ it ( "textToImage" , async ( ) => {
1220+ const res = await client . textToImage ( {
1221+ model : "stabilityai/stable-diffusion-2" ,
1222+ provider : "hyperbolic" ,
1223+ inputs : "award winning high resolution photo of a giant tortoise" ,
1224+ } ) ;
1225+ expect ( res ) . toBeInstanceOf ( Blob ) ;
1226+ } ) ;
1227+
1228+ it ( "textGeneration" , async ( ) => {
1229+ const res = await client . textGeneration ( {
1230+ model : "meta-llama/Llama-3.1-405B-BASE-FP8" ,
1231+ provider : "hyperbolic" ,
1232+ inputs : "Paris is" ,
1233+ parameters : {
1234+ temperature : 0 ,
1235+ max_tokens : 10 ,
1236+ } ,
1237+ } ) ;
1238+ expect ( res ) . toMatchObject ( { generated_text : " city of love" } ) ;
1239+ } ) ;
1240+ } ,
1241+ TIMEOUT
1242+ ) ;
11781243} ) ;
0 commit comments