Method: Mindee::HTTP::Endpoint#predict
- Defined in:
- lib/mindee/http/endpoint.rb
#predict(input_source, opts) ⇒ Array
Call the prediction API.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/mindee/http/endpoint.rb', line 58 def predict(input_source, opts) check_api_key response = predict_req_post( input_source, opts ) if !response.nil? && response.respond_to?(:body) hashed_response = JSON.parse(response.body, object_class: Hash) return [hashed_response, response.body] if ResponseValidation.valid_sync_response?(response) ResponseValidation.clean_request!(response) end raise Errors::MindeeError, 'Could not resolve server response.' if response.nil? error = ErrorHandler.handle_error(@url_name, response) raise error end |