Download tests/unit/test_stream_parser.py from jlshu/vproxy: direct link, hf CLI and curl.
- Browser
- Download file 652 Bytes
-
https://huggingface.co/spaces/jlshu/vproxy/resolve/main/tests/unit/test_stream_parser.py
- Command line
-
hf download hf://spaces/jlshu/vproxy/tests/unit/test_stream_parser.py
-
curl -L -o test_stream_parser.py https://huggingface.co/spaces/jlshu/vproxy/resolve/main/tests/unit/test_stream_parser.py
652 Bytes
| from aistudio_api.infrastructure.gateway.stream_parser import IncrementalJSONStreamParser | |
| def test_stream_parser_extracts_chunk_from_fragmented_input(): | |
| parser = IncrementalJSONStreamParser() | |
| pieces = ['[[[null,"he', 'llo"]]]'] | |
| chunks = [] | |
| for piece in pieces: | |
| chunks.extend(list(parser.feed(piece))) | |
| assert chunks == [[None, "hello"]] | |
| def test_stream_parser_handles_fragmented_xssi_preamble(): | |
| parser = IncrementalJSONStreamParser() | |
| pieces = [")]", "}'\n", '[[[null,"hello"]]]'] | |
| chunks = [] | |
| for piece in pieces: | |
| chunks.extend(list(parser.feed(piece))) | |
| assert chunks == [[None, "hello"]] | |