From 45613e0537adda15b0bcf342be4f770b211d310f 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 7b6f6a8..a19c4df 100644 --- a/api/responder.py +++ b/api/responder.py @@ -151,7 +151,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 'prompt_filter_results' in chunk: continue diff --git a/checks/client.py b/checks/client.py index a149377..e7a8ebe 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