DEV: Don't attempt to update log if completion request fails. (#321)

We already log the request failure when we raise the exception.
This commit is contained in:
Roman Rizzi 2023-11-28 11:15:12 -03:00 committed by GitHub
parent 02f7b368a1
commit 2e7c5f047d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -105,12 +105,14 @@ module DiscourseAi
return response_data return response_data
ensure ensure
log.raw_response_payload = response_raw if log
log.response_tokens = tokenizer.size(response_data) log.raw_response_payload = response_raw
log.save! log.response_tokens = tokenizer.size(response_data)
log.save!
if Rails.env.development? && log if Rails.env.development?
puts "#{self.class.name}: request_tokens #{log.request_tokens} response_tokens #{log.response_tokens}" puts "#{self.class.name}: request_tokens #{log.request_tokens} response_tokens #{log.response_tokens}"
end
end end
end end
end end