forked from phoenix/litellm-mirror
fix(main.py): support cost calculation for text completion streaming object
This commit is contained in:
parent
442ebdde7c
commit
6333fbfe56
3 changed files with 78 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue