File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
packages/tasks/src/snippets Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -313,19 +313,24 @@ export function getPythonInferenceSnippet(
313313 // Example sending an image to the Message API
314314 return snippetConversationalWithImage ( model , accessToken ) ;
315315 } else {
316- const body =
316+ let snippets =
317317 model . pipeline_tag && model . pipeline_tag in pythonSnippets
318- ? pythonSnippets [ model . pipeline_tag ] ?.( model , accessToken ) ?? ""
319- : "" ;
318+ ? pythonSnippets [ model . pipeline_tag ] ?.( model , accessToken ) ?? { content : "" }
319+ : { content : "" } ;
320320
321- return {
322- content : `import requests
321+ snippets = Array . isArray ( snippets ) ? snippets : [ snippets ] ;
323322
323+ return snippets . map ( ( snippet ) => {
324+ return {
325+ ...snippet ,
326+ content : `import requests
327+
324328API_URL = "https://api-inference.huggingface.co/models/${ model . id } "
325329headers = {"Authorization": ${ accessToken ? `"Bearer ${ accessToken } "` : `f"Bearer {API_TOKEN}"` } }
326-
327- ${ body } `,
328- } ;
330+
331+ ${ snippet . content } `,
332+ } ;
333+ } ) ;
329334 }
330335}
331336
You can’t perform that action at this time.
0 commit comments