haystack icon indicating copy to clipboard operation
haystack copied to clipboard

streaming_callback with async functions

Open Filocava99 opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. Currently the streaming_callback for chat generators do not support async functions as callbacks, limiting the potential of backend solutions made, for instance, with FastAPI.

Describe the solution you'd like Make streaming_callback accept both Optional[Callable[[StreamingChunk], None]] and Optional[(chunk: StreamingChunk) -> Coroutine[Any, Any, None]

Describe alternatives you've considered As of now the alternative is to run the pipeline on a different thread and then use appropriate data structures to concurrently add data from the callback and retrieve them from FastAPI main thread. This way the code is clunky and not optimal

Filocava99 avatar Feb 28 '24 08:02 Filocava99

Bump

Filocava99 avatar Mar 06 '24 15:03 Filocava99

Anyone figured out how we can stream tokens from the generator thru fastapi back to the user?

WissamAntoun avatar May 19 '24 22:05 WissamAntoun

Blocked by #6012

shadeMe avatar Jun 14 '24 11:06 shadeMe