mirror of
https://github.com/ollama/ollama-python.git
synced 2026-01-14 06:07:17 +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={}))]
|
>>> msg['tool_calls'] = [Message.ToolCall(function=Message.ToolCall.Function(name='foo', arguments={}))]
|
||||||
>>> 'tool_calls' in msg
|
>>> 'tool_calls' in msg
|
||||||
True
|
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:
|
def get(self, key: str, default: Any = None) -> Any:
|
||||||
return getattr(self, key, default)
|
return getattr(self, key, default)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user