Skip to content

Commit 00c6433

Browse files
committed
check defaults that aren't None too
1 parent 986fb4c commit 00c6433

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ollama/_types.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,17 @@ def __contains__(self, key: str) -> bool:
4545
>>> msg['tool_calls'] = [Message.ToolCall(function=Message.ToolCall.Function(name='foo', arguments={}))]
4646
>>> 'tool_calls' in msg
4747
True
48+
>>> tool = Tool()
49+
>>> 'type' in tool
50+
True
4851
"""
49-
return key in self.model_fields_set
52+
if key in self.model_fields_set:
53+
return True
54+
55+
if key in self.model_fields:
56+
return self.model_fields[key].default is not None
57+
58+
return False
5059

5160
def get(self, key: str, default: Any = None) -> Any:
5261
return getattr(self, key, default)

0 commit comments

Comments
 (0)