Skip to content

Commit

Permalink
Improve parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AliSoftware committed Dec 2, 2024
1 parent 5a6fd7e commit 96fe170
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def self.run(params)
case response
when Net::HTTPOK
json = JSON.parse(response.body)
best_choice = json['choices']&.first
UI.abort_with_message!("Unable to parse OpenAPI response\n#{json}") if best_choice.nil?
best_choice['message']['content']
json['choices']&.first&.dig('message', 'content')
else
UI.user_error!("Error in OpenAPI API response: #{response}. #{response.body}")
end
Expand Down

0 comments on commit 96fe170

Please sign in to comment.