Skip to content

Commit

Permalink
fix 'content' check on messages in chat()
Browse files Browse the repository at this point in the history
  • Loading branch information
DSLstandard committed Apr 15, 2024
1 parent 2fde317 commit dc9543b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ollama/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def chat(
raise TypeError('messages must be a list of Message or dict-like objects')
if not (role := message.get('role')) or role not in ['system', 'user', 'assistant']:
raise RequestError('messages must contain a role and it must be one of "system", "user", or "assistant"')
if not message.get('content'):
if 'content' not in message:
raise RequestError('messages must contain content')
if images := message.get('images'):
message['images'] = [_encode_image(image) for image in images]
Expand Down Expand Up @@ -449,7 +449,7 @@ async def chat(
raise TypeError('messages must be a list of strings')
if not (role := message.get('role')) or role not in ['system', 'user', 'assistant']:
raise RequestError('messages must contain a role and it must be one of "system", "user", or "assistant"')
if not message.get('content'):
if 'content' not in message:
raise RequestError('messages must contain content')
if images := message.get('images'):
message['images'] = [_encode_image(image) for image in images]
Expand Down

0 comments on commit dc9543b

Please sign in to comment.