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
8 files
+ 180
45
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -2,32 +2,22 @@
@@ -2,32 +2,22 @@
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: generate_response, status: :ok }
format.any { head :bad_request }
format.any { head :bad_request }
end
end
end
end
private
private
def permitted_params
def generate_response
params.permit(:q)
::Gitlab::Llm::TanukiBot.execute(current_user: current_user, question: params.require(:q))
end
def service
::Gitlab::Llm::TanukiBot.new(current_user: current_user, question: permitted_params[:q])
end
end
end
end
end
end
Loading