Skip to content
Snippets Groups Projects

Create initial Tanuki bot api endpoint

Merged Terri Chu requested to merge tchu-bot-create-new-api into master
All threads resolved!
Compare and Show latest version
5 files
+ 35
67
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -2,18 +2,12 @@
@@ -2,18 +2,12 @@
module Llm
module Llm
class TanukiBotController < ApplicationController
class TanukiBotController < ApplicationController
# TODO - ignore non json requests, maybe need to do this in routes config with constraints
# ActionController::InvalidAuthenticityToken
# check with frontend to see if we need this
skip_before_action :verify_authenticity_token
skip_before_action :verify_authenticity_token
wrap_parameters format: []
wrap_parameters format: []
feature_category :global_search
feature_category :global_search
def ask
def ask
# setting content-type to application/xml or html throws an error in the service
# the respond_to isn't working the way we expect and needs to be fixed
respond_to do |format|
respond_to do |format|
format.json { render json: service.execute, status: :ok }
format.json { render json: service.execute, status: :ok }
format.any { head :bad_request }
format.any { head :bad_request }
@@ -22,12 +16,8 @@ def ask
@@ -22,12 +16,8 @@ def ask
private
private
def permitted_params
params.permit(:q)
end
def service
def service
::Gitlab::Llm::TanukiBot.new(current_user: current_user, question: permitted_params[:q])
::Gitlab::Llm::TanukiBot.new(current_user: current_user, question: params.require(:q))
end
end
end
end
end
end
Loading