Skip to content

Commit c2d69ad

Browse files
authored
Update extension for cloud streaming use (#1163)
1 parent a3a7a95 commit c2d69ad

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pgml-extension/src/bindings/transformers/transformers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,16 @@ def create_pipeline(task):
312312
return pipe
313313

314314

315-
def transform_using(pipeline, args, inputs):
315+
def transform_using(pipeline, args, inputs, stream=False):
316316
args = orjson.loads(args)
317317
inputs = orjson.loads(inputs)
318318

319319
if pipeline.task == "question-answering":
320320
inputs = [orjson.loads(input) for input in inputs]
321321
convert_eos_token(pipeline.tokenizer, args)
322322

323+
if stream:
324+
return pipeline.stream(inputs, **args)
323325
return orjson.dumps(pipeline(inputs, **args), default=orjson_default).decode()
324326

325327

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy