mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
(fix) anyscale streaming detect [DONE] special char
This commit is contained in:
parent
6b40546e59
commit
56ba58b35b
1 changed files with 7 additions and 1 deletions
|
@ -3800,7 +3800,13 @@ class CustomStreamWrapper:
|
||||||
text = ""
|
text = ""
|
||||||
is_finished = False
|
is_finished = False
|
||||||
finish_reason = None
|
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:])
|
data_json = json.loads(str_line[5:])
|
||||||
print_verbose(f"delta content: {data_json['choices'][0]['delta']}")
|
print_verbose(f"delta content: {data_json['choices'][0]['delta']}")
|
||||||
text = data_json["choices"][0]["delta"].get("content", "")
|
text = data_json["choices"][0]["delta"].get("content", "")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue