fix(main.py): support cost calculation for text completion streaming object

This commit is contained in:
Krrish Dholakia 2024-01-08 12:41:08 +05:30
parent 442ebdde7c
commit 6333fbfe56
3 changed files with 78 additions and 2 deletions

View file

@ -558,6 +558,13 @@ class TextChoices(OpenAIObject):
def __setitem__(self, key, value):
# Allow dictionary-style assignment of attributes
setattr(self, key, value)
def json(self, **kwargs):
try:
return self.model_dump() # noqa
except:
# if using pydantic v1
return self.dict()
class TextCompletionResponse(OpenAIObject):