Update ollama/_types.py

Co-authored-by: Parth Sareen <parth.sareen@ollama.com>
This commit is contained in:
Jeffrey Morgan 2024-11-26 10:41:53 -08:00 committed by GitHub
parent d8d98e17b2
commit d4c38978d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,6 +93,9 @@ class SubscriptableBaseModel(BaseModel):
>>> msg = Message(role='user')
>>> msg.get('nonexistent', 'default')
'default'
>>> msg = Message(role='user', tool_calls=[ Message.ToolCall(function=Message.ToolCall.Function(name='foo', arguments={}))])
>>> msg.get('tool_calls')[0]['function']['name']
'foo'
"""
return self[key] if key in self else default