@@ -2401,4 +2401,62 @@ describe.skip("InferenceClient", () => {
24012401 } ,
24022402 TIMEOUT
24032403 ) ;
2404+
2405+ describe . concurrent (
2406+ "clarifai" ,
2407+ ( ) => {
2408+ const client = new InferenceClient ( env . HF_CLARIFAI_KEY ?? "dummy" ) ;
2409+
2410+ HARDCODED_MODEL_INFERENCE_MAPPING [ "clarifai" ] = {
2411+ "deepseek-ai/DeepSeek-V3.1" : {
2412+ provider : "clarifai" ,
2413+ hfModelId : "deepseek-ai/DeepSeek-V3.1" ,
2414+ providerId : "deepseek-ai/deepseek-chat/models/DeepSeek-V3_1" ,
2415+ status : "live" ,
2416+ task : "conversational" ,
2417+ } ,
2418+ } ;
2419+
2420+ it ( "chatCompletion - DeepSeek-V3_1" , async ( ) => {
2421+ const res = await client . chatCompletion ( {
2422+ model : "deepseek-ai/DeepSeek-V3.1" ,
2423+ provider : "clarifai" ,
2424+ messages : [ { role : "user" , content : "What is 5 + 3?" } ] ,
2425+ max_tokens : 20 ,
2426+ } ) ;
2427+ if ( res . choices && res . choices . length > 0 ) {
2428+ const completion = res . choices [ 0 ] . message ?. content ;
2429+ expect ( completion ) . toBeDefined ( ) ;
2430+ expect ( typeof completion ) . toBe ( "string" ) ;
2431+ expect ( completion ) . toMatch ( / ( e i g h t | 8 ) / i) ;
2432+ }
2433+ } ) ;
2434+
2435+ it ( "chatCompletion stream - DeepSeek-V3_1" , async ( ) => {
2436+ const stream = client . chatCompletionStream ( {
2437+ model : "deepseek-ai/DeepSeek-V3.1" ,
2438+ provider : "clarifai" ,
2439+ messages : [ { role : "user" , content : "Count from 1 to 3" } ] ,
2440+ stream : true ,
2441+ max_tokens : 20 ,
2442+ } ) as AsyncGenerator < ChatCompletionStreamOutput > ;
2443+
2444+ let fullResponse = "" ;
2445+ for await ( const chunk of stream ) {
2446+ if ( chunk . choices && chunk . choices . length > 0 ) {
2447+ const content = chunk . choices [ 0 ] . delta ?. content ;
2448+ if ( content ) {
2449+ fullResponse += content ;
2450+ }
2451+ }
2452+ }
2453+
2454+ // Verify we got a meaningful response
2455+ expect ( fullResponse ) . toBeTruthy ( ) ;
2456+ expect ( fullResponse . length ) . toBeGreaterThan ( 0 ) ;
2457+ expect ( fullResponse ) . toMatch ( / 1 .* 2 .* 3 / ) ;
2458+ } ) ;
2459+ } ,
2460+ TIMEOUT
2461+ ) ;
24042462} ) ;
0 commit comments