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(
313
313
// Example sending an image to the Message API
314
314
return snippetConversationalWithImage ( model , accessToken ) ;
315
315
} else {
316
- const body =
316
+ let snippets =
317
317
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 : "" } ;
320
320
321
- return {
322
- content : `import requests
321
+ snippets = Array . isArray ( snippets ) ? snippets : [ snippets ] ;
323
322
323
+ return snippets . map ( ( snippet ) => {
324
+ return {
325
+ ...snippet ,
326
+ content : `import requests
327
+
324
328
API_URL = "https://api-inference.huggingface.co/models/${ model . id } "
325
329
headers = {"Authorization": ${ accessToken ? `"Bearer ${ accessToken } "` : `f"Bearer {API_TOKEN}"` } }
326
-
327
- ${ body } `,
328
- } ;
330
+
331
+ ${ snippet . content } `,
332
+ } ;
333
+ } ) ;
329
334
}
330
335
}
331
336
You can’t perform that action at this time.
0 commit comments