mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-13 21:57:16 +08:00
check defaults that aren't None too
This commit is contained in:
parent
986fb4c7b3
commit
00c64332cc
@ -45,8 +45,17 @@ class SubscriptableBaseModel(BaseModel):
|
||||
>>> msg['tool_calls'] = [Message.ToolCall(function=Message.ToolCall.Function(name='foo', arguments={}))]
|
||||
>>> 'tool_calls' in msg
|
||||
True
|
||||
>>> tool = Tool()
|
||||
>>> 'type' in tool
|
||||
True
|
||||
"""
|
||||
return key in self.model_fields_set
|
||||
if key in self.model_fields_set:
|
||||
return True
|
||||
|
||||
if key in self.model_fields:
|
||||
return self.model_fields[key].default is not None
|
||||
|
||||
return False
|
||||
|
||||
def get(self, key: str, default: Any = None) -> Any:
|
||||
return getattr(self, key, default)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user