Sha256: d1d4af03d0f58993673bb8253f7232b619ed24b98268bf46490e5bfa56985ec6

Contents?: true

Size: 559 Bytes

Versions: 11

Compression:

Stored size: 559 Bytes

Contents

module EasyML
  class PredictionsController < ApplicationController
    skip_before_action :verify_authenticity_token, only: [:create]

    def create
      model_name = params[:model]
      input = params[:input]

      predictions = EasyML::Predict.predict(model_name, input)

      render json: { prediction: predictions.first }
    rescue ActiveRecord::RecordNotFound
      render json: { error: "Model not found" }, status: :not_found
    rescue StandardError => e
      render json: { error: e.message }, status: :unprocessable_entity
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
easy_ml-0.2.0.pre.rc38 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc37 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc36 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc35 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc34 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc33 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc32 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc31 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc30 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc29 app/controllers/easy_ml/predictions_controller.rb
easy_ml-0.2.0.pre.rc28 app/controllers/easy_ml/predictions_controller.rb