7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/neuron_ai_chatbot/api/v1/chat_controller.rb', line 7
def create
user_input = params[:message]
return render json: { error: "Message cannot be blank" }, status: :bad_request if user_input.blank?
ai_output, api_response = LocalAiService.run_chat(user_input)
return render json: format_ai_parse_failure(user_input, ai_output), status: :unprocessable_entity if ai_parse_error?(ai_output)
final_response = ResponseProcessor.process(ai_output, api_response || {})
render json: format_response(user_input, ai_output, final_response, api_response),
status: chat_http_status(ai_output, api_response, final_response)
end
|