@@ -115,19 +115,22 @@ export function getInferenceSnippet(
115115 id : string ,
116116 pipeline_tag : PipelineType ,
117117 language : InferenceSnippetLanguage ,
118+ config ?: JsonObject ,
119+ tags ?: string [ ] ,
118120) : string | undefined {
119121 const modelData = {
120122 id,
121123 pipeline_tag,
122124 mask_token : "[MASK]" ,
123125 library_name : "" ,
124- config : { } ,
125- tags : [ ] ,
126+ config : config ?? { } ,
127+ tags : tags ?? [ ] ,
126128 } ;
127129 // @ts -ignore
128130 if ( HAS_SNIPPET_FN [ language ] ( modelData ) ) {
129131 // @ts -ignore
130- return GET_SNIPPET_FN [ language ] ( modelData , "hf_***" ) ;
132+ const snippets = GET_SNIPPET_FN [ language ] ( modelData , "hf_***" ) ;
133+ return Array . isArray ( snippets ) ? snippets [ 0 ] . content : snippets . content ;
131134 }
132135}
133136
@@ -472,25 +475,13 @@ function fetchChatCompletion() {
472475 ) ;
473476
474477 const mainModel = DATA . models [ task . name ] [ 0 ] ;
475- const mainModelData = {
476- // @ts -ignore
477- id : mainModel . id ,
478- pipeline_tag : task . pipelineTag ,
479- mask_token : "" ,
480- library_name : "" ,
481- // @ts -ignore
482- tags : [ "conversational" ] ,
483- // @ts -ignore
484- config : mainModel . config ,
485- } ;
486-
487478 const taskSnippets = {
488479 // @ts -ignore
489- curl : GET_SNIPPET_FN [ "curl" ] ( mainModelData , "hf_***" ) ,
480+ curl : getInferenceSnippet ( mainModel . id , task . pipelineTag , "curl" , mainModel . config , [ "conversational" ] ) ,
490481 // @ts -ignore
491- python : GET_SNIPPET_FN [ "python" ] ( mainModelData , "hf_***" ) ,
482+ python : getInferenceSnippet ( mainModel . id , task . pipelineTag , "python" , mainModel . config , [ "conversational" ] ) ,
492483 // @ts -ignore
493- javascript : GET_SNIPPET_FN [ "js" ] ( mainModelData , "hf_***" ) ,
484+ javascript : getInferenceSnippet ( mainModel . id , task . pipelineTag , "js" , mainModel . config , [ "conversational" ] ) ,
494485 } ;
495486 DATA . snippets [ task . name ] = SNIPPETS_TEMPLATE ( {
496487 taskSnippets,
0 commit comments