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
ensure
log.raw_response_payload = response_raw
log.response_tokens = tokenizer.size(response_data)
log.save!
if log
log.raw_response_payload = response_raw
log.response_tokens = tokenizer.size(response_data)
log.save!
if Rails.env.development? && log
puts "#{self.class.name}: request_tokens #{log.request_tokens} response_tokens #{log.response_tokens}"
if Rails.env.development?
puts "#{self.class.name}: request_tokens #{log.request_tokens} response_tokens #{log.response_tokens}"
end
end
end
end