Skip to content

Commit

Permalink
fix(chat): add error handling for failed message saving
Browse files Browse the repository at this point in the history
  • Loading branch information
The0mikkel committed Jun 27, 2024
1 parent bb8db4f commit e32d5e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,12 @@ async def chat(self, channel_id):
response_message = ''
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']
await self.save_message(channel_id, response_message, 'assistant')
try:
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
except Exception as e:
Expand Down

0 comments on commit e32d5e4

Please sign in to comment.