9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/ai_screen_analyzer/ai_analyzer_controller.rb', line 9
def analyze_screen
begin
image_data = params[:image]
prompt = params[:prompt]
return render_error('Imagem não fornecida') if image_data.blank?
return render_error('Prompt não fornecido') if prompt.blank?
image_data = image_data.sub(/^data:image\/\w+;base64,/, '')
analysis = analyze_with_gpt4v(image_data, prompt)
render json: {
success: true,
analysis: analysis
}
rescue StandardError => e
render_error(e.message)
end
end
|