From 83df730edb9e6b94ccb8f2d4c7bc72398d4c306a Mon Sep 17 00:00:00 2001 From: monosans Date: Sun, 8 Oct 2023 16:13:28 +0300 Subject: [PATCH] Replace only first occurrence of data: in response --- api/responder.py | 2 +- checks/client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/responder.py b/api/responder.py index e515c84..3faaa12 100644 --- a/api/responder.py +++ b/api/responder.py @@ -153,7 +153,7 @@ async def respond( chunk = chunk.decode('utf8').strip() if 'azure' in provider_name: - chunk = chunk.strip().replace('data: ', '') + chunk = chunk.strip().replace('data: ', '', 1) if not chunk or chunk_no == 1: continue diff --git a/checks/client.py b/checks/client.py index 7410c23..f6fe5d1 100644 --- a/checks/client.py +++ b/checks/client.py @@ -100,7 +100,7 @@ async def test_chat_stream_gpt3() -> float: async for chunk in response.aiter_text(): for subchunk in chunk.split('\n\n'): - chunk = subchunk.replace('data: ', '').strip() + chunk = subchunk.replace('data: ', '', 1).strip() if chunk == '[DONE]': break