ollama / ollama-python

Ollama Python library
https://ollama.com
MIT License
2.69k stars 221 forks source link

fix 'content' check on messages in chat() #118

Closed DSLstandard closed 2 months ago

DSLstandard commented 2 months ago

In chat() in Client and AsyncClient, if message['content'] is "",

the following would raise an error since bool("") also returns False like bool(None):

if not message.get('content'):
  raise RequestError('messages must contain content')

Doing the following would fix it:

if 'content' not in message:
  raise RequestError('messages must contain content')

As far as I know ollama does not explicitly prohibit empty content in messages.

mxyng commented 2 months ago

Thanks!