fix(chat): add error handling for failed message saving
This commit is contained in:
parent
bb8db4f3d7
commit
e32d5e41e0
8
bot.py
8
bot.py
@ -238,8 +238,12 @@ class Bot:
|
|||||||
response_message = ''
|
response_message = ''
|
||||||
data = await self.ollama.chat(model=self.model, keep_alive=-1, stream=False, messages=local_messages, options={'num_ctx': self.ctx})
|
data = await self.ollama.chat(model=self.model, keep_alive=-1, stream=False, messages=local_messages, options={'num_ctx': self.ctx})
|
||||||
|
|
||||||
response_message = data['message']['content']
|
try:
|
||||||
await self.save_message(channel_id, response_message, 'assistant')
|
response_message = data['message']['content']
|
||||||
|
await self.save_message(channel_id, response_message, 'assistant')
|
||||||
|
except Exception as e:
|
||||||
|
logging.error('Error saving response: %s', e)
|
||||||
|
return 'I am sorry, I am unable to respond at the moment.'
|
||||||
|
|
||||||
return response_message
|
return response_message
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user