mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 19:24:27 +00:00
(fix) anyscale streaming detect [DONE] special char
This commit is contained in:
parent
d0b23a2722
commit
e53f5316d0
1 changed files with 7 additions and 1 deletions
|
@ -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", "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue