mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
(fix) streaming completion azure
This commit is contained in:
parent
9e88014ff4
commit
69b6712707
1 changed files with 7 additions and 3 deletions
|
@ -4867,13 +4867,17 @@ class CustomStreamWrapper:
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
elif response_obj is not None and response_obj.get("original_chunk", None) is not None: # function / tool calling branch - only set for openai/azure compatible endpoints
|
elif response_obj is not None and response_obj.get("original_chunk", None) is not None: # function / tool calling branch - only set for openai/azure compatible endpoints
|
||||||
|
# enter this branch when no content has been passed in response
|
||||||
original_chunk = response_obj.get("original_chunk", None)
|
original_chunk = response_obj.get("original_chunk", None)
|
||||||
model_response.id = original_chunk.id
|
model_response.id = original_chunk.id
|
||||||
|
try:
|
||||||
delta = dict(original_chunk.choices[0].delta)
|
delta = dict(original_chunk.choices[0].delta)
|
||||||
model_response.choices[0].delta = Delta(**delta)
|
model_response.choices[0].delta = Delta(**delta)
|
||||||
|
except:
|
||||||
|
model_response.choices[0].delta = Delta()
|
||||||
model_response.system_fingerprint = original_chunk.system_fingerprint
|
model_response.system_fingerprint = original_chunk.system_fingerprint
|
||||||
if self.sent_first_chunk == False:
|
if self.sent_first_chunk == False:
|
||||||
completion_obj["role"] = "assistant"
|
model_response.choices[0].delta["role"] = "assistant"
|
||||||
self.sent_first_chunk = True
|
self.sent_first_chunk = True
|
||||||
threading.Thread(target=self.logging_obj.success_handler, args=(model_response,)).start() # log response
|
threading.Thread(target=self.logging_obj.success_handler, args=(model_response,)).start() # log response
|
||||||
return model_response
|
return model_response
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue