fix: undefined method first for nil:NilClass (#7567)

Co-authored-by: Sojan Jose <sojan@pepalo.com>
This commit is contained in:
Shivam Mishra
2023-07-24 12:48:53 +05:30
committed by Sojan
parent 4b27fdf4db
commit 39f14bebbd

View File

@@ -75,6 +75,8 @@ class Integrations::OpenaiBaseService
}
response = HTTParty.post(API_URL, headers: headers, body: body)
JSON.parse(response.body)['choices'].first['message']['content']
choices = JSON.parse(response.body)['choices']
choices.present? ? choices.first['message']['content'] : nil
end
end