This PR fixes a bug with ChatPipeline where streaming code would throw a TypeError, now the execution is as expected
Reproduction Code:
from deepsparse import Pipeline
import inspect
streaming = True
input_text = "def fib("
chat_pipeline = Pipeline.create(
task="chat",
model_path="/home/rahul/.cache/sparsezoo/neuralmagic/codegen_mono-350m-bigpython_bigquery_thepile-base/deployment",
)
predictions = chat_pipeline(**{"sequences": [input_text]}, streaming=streaming)
assert inspect.isgenerator(predictions), "Predictions should be a generator"
for i, prediction in enumerate(predictions):
print(f"Prediction {i}: {prediction}")
Output:
Before this PR:
File
"/home/rahul/projects/deepsparse/src/deepsparse/pipeline.py", line 284, in __call__
pipeline_outputs = self.process_engine_outputs(engine_outputs, **context)
File "/home/rahul/projects/deepsparse/src/deepsparse/transformers/pipelines/chat.py", line 149, in process_engine_outputs
return ChatOutput(**text_generation_output.dict(), session_ids=session_ids)
AttributeError: 'generator' object has no attribute 'dict'
This PR fixes a bug with
ChatPipeline
where streaming code would throw aTypeError
, now the execution is as expectedReproduction Code:
Output:
Before this PR:
After this PR:
Also added an automated test!