[Bugfix]if the content is started with ":"(response of ping), client should i… (#5303)

Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
Co-authored-by: Roger Wang <ywang@roblox.com>
This commit is contained in:
Wang, Yi 2024-06-13 11:16:41 +08:00 committed by GitHub
parent 916d219d62
commit 88407532e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,9 +68,13 @@ async def async_request_tgi(
chunk_bytes = chunk_bytes.strip()
if not chunk_bytes:
continue
chunk_bytes = chunk_bytes.decode("utf-8")
chunk = remove_prefix(chunk_bytes.decode("utf-8"),
"data:")
#NOTE: Sometimes TGI returns a ping response without
# any data, we should skip it.
if chunk_bytes.startswith(":"):
continue
chunk = remove_prefix(chunk_bytes, "data:")
data = json.loads(chunk)
timestamp = time.perf_counter()