mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-17 14:16:54 +00:00
(fix) anyscale streaming detect [DONE] special char
This commit is contained in:
+7
-1
@@ -3800,7 +3800,13 @@ class CustomStreamWrapper:
|
||||
text = ""
|
||||
is_finished = False
|
||||
finish_reason = None
|
||||
if str_line.startswith("data:"):
|
||||
if str_line == "data: [DONE]":
|
||||
# anyscale returns a [DONE] special char for streaming, this cannot be json loaded. This is the end of stream
|
||||
text = ""
|
||||
is_finished = True
|
||||
finish_reason = "stop"
|
||||
return {"text": text, "is_finished": is_finished, "finish_reason": finish_reason}
|
||||
elif str_line.startswith("data:"):
|
||||
data_json = json.loads(str_line[5:])
|
||||
print_verbose(f"delta content: {data_json['choices'][0]['delta']}")
|
||||
text = data_json["choices"][0]["delta"].get("content", "")
|
||||
|
||||
Reference in New Issue
Block a user