@@ -3,7 +3,7 @@ import { assert, describe, expect, it } from "vitest";
3
3
import type { ChatCompletionStreamOutput } from "@huggingface/tasks" ;
4
4
5
5
import type { TextToImageArgs } from "../src" ;
6
- import { chatCompletion , HfInference } from "../src" ;
6
+ import { chatCompletion , chatCompletionStream , HfInference , textGeneration , textToImage } from "../src" ;
7
7
import { textToVideo } from "../src/tasks/cv/textToVideo" ;
8
8
import { readTestFile } from "./test-files" ;
9
9
import "./vcr" ;
@@ -1180,8 +1180,6 @@ describe.concurrent("HfInference", () => {
1180
1180
describe . concurrent (
1181
1181
"Hyperbolic" ,
1182
1182
( ) => {
1183
- const client = new HfInference ( env . HF_HYPERBOLIC_KEY ) ;
1184
-
1185
1183
HARDCODED_MODEL_ID_MAPPING . hyperbolic = {
1186
1184
"meta-llama/Llama-3.2-3B-Instruct" : "meta-llama/Llama-3.2-3B-Instruct" ,
1187
1185
"meta-llama/Llama-3.3-70B-Instruct" : "meta-llama/Llama-3.3-70B-Instruct" ,
@@ -1190,7 +1188,8 @@ describe.concurrent("HfInference", () => {
1190
1188
} ;
1191
1189
1192
1190
it ( "chatCompletion - hyperbolic" , async ( ) => {
1193
- const res = await client . chatCompletion ( {
1191
+ const res = await chatCompletion ( {
1192
+ accessToken : env . HF_HYPERBOLIC_KEY ,
1194
1193
model : "meta-llama/Llama-3.2-3B-Instruct" ,
1195
1194
provider : "hyperbolic" ,
1196
1195
messages : [ { role : "user" , content : "Complete this sentence with words, one plus one is equal " } ] ,
@@ -1210,7 +1209,8 @@ describe.concurrent("HfInference", () => {
1210
1209
} ) ;
1211
1210
1212
1211
it ( "chatCompletion stream" , async ( ) => {
1213
- const stream = client . chatCompletionStream ( {
1212
+ const stream = chatCompletionStream ( {
1213
+ accessToken : env . HF_HYPERBOLIC_KEY ,
1214
1214
model : "meta-llama/Llama-3.3-70B-Instruct" ,
1215
1215
provider : "hyperbolic" ,
1216
1216
messages : [ { role : "user" , content : "Complete the equation 1 + 1 = , just the answer" } ] ,
@@ -1225,12 +1225,12 @@ describe.concurrent("HfInference", () => {
1225
1225
} ) ;
1226
1226
1227
1227
it ( "textToImage" , async ( ) => {
1228
- const res = await client . textToImage ( {
1228
+ const res = await textToImage ( {
1229
+ accessToken : env . HF_HYPERBOLIC_KEY ,
1229
1230
model : "stabilityai/stable-diffusion-2" ,
1230
1231
provider : "hyperbolic" ,
1231
1232
inputs : "award winning high resolution photo of a giant tortoise" ,
1232
1233
parameters : {
1233
- model_name : "SD2" ,
1234
1234
height : 128 ,
1235
1235
width : 128 ,
1236
1236
} ,
@@ -1239,13 +1239,16 @@ describe.concurrent("HfInference", () => {
1239
1239
} ) ;
1240
1240
1241
1241
it ( "textGeneration" , async ( ) => {
1242
- const res = await client . textGeneration ( {
1242
+ const res = await textGeneration ( {
1243
+ accessToken : env . HF_HYPERBOLIC_KEY ,
1243
1244
model : "meta-llama/Llama-3.1-405B" ,
1244
1245
provider : "hyperbolic" ,
1245
- messages : [ { role : "user" , content : "Paris is" } ] ,
1246
- temperature : 0 ,
1247
- top_p : 0.01 ,
1248
- max_tokens : 10 ,
1246
+ inputs : "Paris is" ,
1247
+ parameters : {
1248
+ temperature : 0 ,
1249
+ top_p : 0.01 ,
1250
+ max_new_tokens : 10 ,
1251
+ }
1249
1252
} ) ;
1250
1253
expect ( res ) . toMatchObject ( { generated_text : "...the capital and most populous city of France," } ) ;
1251
1254
} ) ;
0 commit comments