From 8a6fb069ef91dfaa0c4af4aa103c78b9de905b17 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Wed, 23 Jul 2025 13:48:27 +0530 Subject: [PATCH] fix: handling random string in the chunk --- portkey_ai/api_resources/apis/chat_complete.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/portkey_ai/api_resources/apis/chat_complete.py b/portkey_ai/api_resources/apis/chat_complete.py index a50f8824..5a5a6c5f 100644 --- a/portkey_ai/api_resources/apis/chat_complete.py +++ b/portkey_ai/api_resources/apis/chat_complete.py @@ -94,6 +94,8 @@ def stream_create( # type: ignore[return] json_string = json_string.strip().rstrip("\n") if json_string == "": continue + if json_string.startswith(":"): + continue elif json_string == "[DONE]": break elif json_string != "": @@ -342,6 +344,8 @@ async def stream_create( json_string = json_string.strip().rstrip("\n") if json_string == "": continue + if json_string.startswith(":"): + continue elif json_string == "[DONE]": break elif json_string != "":