Class: CompletionKit::ImportsController
Constant Summary
ApplicationController::ONBOARDING_DISMISS_COOKIE
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/completion_kit/imports_controller.rb', line 6
def create
if upload_too_large?(params[:file])
flash.now[:alert] = "That file is too large. The limit is #{CompletionKit.config.max_upload_bytes / (1024 * 1024)} MB."
return render :new, status: :payload_too_large
end
content = uploaded_content
if content.blank?
flash.now[:alert] = "Paste or upload a promptfooconfig.yaml to import."
return render :new, status: :unprocessable_entity
end
@result = PromptfooImporter.call(content)
if @result.ok
render :create
else
flash.now[:alert] = @result.error
render :new, status: :unprocessable_entity
end
end
|
#new ⇒ Object
3
4
|
# File 'app/controllers/completion_kit/imports_controller.rb', line 3
def new
end
|