mirror of
https://github.com/bentoml/OpenLLM.git
synced 2026-01-31 02:41:51 -05:00
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
35 lines
1.3 KiB
Python
Generated
35 lines
1.3 KiB
Python
Generated
"""This type stub file was generated by pyright."""
|
|
|
|
json_decoder = ...
|
|
|
|
def stream_as_text(stream): # -> Generator[Unknown | str, Any, None]:
|
|
"""Given a stream of bytes or text, if any of the items in the stream
|
|
are bytes convert them to text.
|
|
This function can be removed once we return text streams
|
|
instead of byte streams.
|
|
"""
|
|
...
|
|
|
|
def json_splitter(buffer): # -> tuple[Any, Unknown] | None:
|
|
"""Attempt to parse a json object from a buffer. If there is at least one
|
|
object, return it and the rest of the buffer, otherwise return None.
|
|
"""
|
|
...
|
|
|
|
def json_stream(stream): # -> Generator[Any, Any, None]:
|
|
"""Given a stream of text, return a stream of json objects.
|
|
This handles streams which are inconsistently buffered (some entries may
|
|
be newline delimited, and others are not).
|
|
"""
|
|
...
|
|
|
|
def line_splitter(buffer, separator=...): ...
|
|
def split_buffer(stream, splitter=..., decoder=...): # -> Generator[Unknown | str, Any, None]:
|
|
"""Given a generator which yields strings and a splitter function,
|
|
joins all input, splits on the separator and yields each chunk.
|
|
Unlike string.split(), each chunk includes the trailing
|
|
separator, except for the last one if none was found on the end
|
|
of the input.
|
|
"""
|
|
...
|