mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
feat(ChatCompletionDeltaToolCall): add dictionary-like access methods
Add dictionary-style access support to ChatCompletionDeltaToolCall class: - Add __contains__ for 'in' operator support - Add get() method with default value support - Add __getitem__ for dict-style access This makes the class more flexible by supporting both object and dictionary access patterns.
This commit is contained in:
parent
0c0498dd60
commit
596845726e
1 changed files with 12 additions and 0 deletions
|
@ -281,6 +281,18 @@ class ChatCompletionDeltaToolCall(OpenAIObject):
|
|||
type: Optional[str] = None
|
||||
index: int
|
||||
|
||||
def __contains__(self, key):
|
||||
# Define custom behavior for the 'in' operator
|
||||
return hasattr(self, key)
|
||||
|
||||
def get(self, key, default=None):
|
||||
# Custom .get() method to access attributes with a default value if the attribute doesn't exist
|
||||
return getattr(self, key, default)
|
||||
|
||||
def __getitem__(self, key):
|
||||
# Allow dictionary-style access to attributes
|
||||
return getattr(self, key)
|
||||
|
||||
|
||||
class HiddenParams(OpenAIObject):
|
||||
original_response: Optional[Union[str, Any]] = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue