add customstreapwrapper for openai streaming

This commit is contained in:
ishaan-jaff 2023-08-28 15:28:51 -07:00
parent 0158e12701
commit 69f9c40d80
2 changed files with 9 additions and 1 deletions

View file

@ -195,7 +195,9 @@ def completion(
response = openai.ChatCompletion.create(
engine=model, messages=messages, **optional_params
)
if "stream" in optional_params and optional_params["stream"] == True:
response = CustomStreamWrapper(response, model)
return response
## LOGGING
logging.post_call(
input=messages,
@ -251,6 +253,9 @@ def completion(
response = openai.ChatCompletion.create(
model=model, messages=messages, **optional_params
)
if "stream" in optional_params and optional_params["stream"] == True:
response = CustomStreamWrapper(response, model)
return response
## LOGGING
logging.post_call(
input=messages,