Skip to content

Tanuki Bot: Graphql

Madelein van Niekerk requested to merge tanuki-bot/graphql into master

What does this MR do and why?

related https://gitlab.com/gitlab-org/enablement-section/tanuki-bot/-/issues/23

Creates a Graphql endpoint for Tanuki Bot.

The request is made with a question and user:

mutation tanuki_bot {
  aiAction(
    input: {tanukiBot: {question: "how do I change my password?", resourceId: "gid://gitlab/User/1"}}
    ) {
    	clientMutationId
        errors
    }
}

And responds via a Subscription aiCompletionResponse:

{:id=>"933e44ed-7c19-412b-b66c-ea3ed45157e3", :model_name=>"User", :response_body=>"{:msg=>\"To change your password, on the top bar in the upper-right corner, select your avatar and select Edit profile. On the left sidebar, select Password. In the Current password, New password and Password confirmation text boxes, enter the required details and select Save password.\", :sources=>[{\"info\"=>\"To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments\", \"group\"=>\"Authentication and Authorization\", \"stage\"=>\"Manage\", \"source\"=>\"doc/user/profile/user_passwords.md\", \"source_type\"=>\"doc\"}]}", :errors=>[]}

On Gitlab.com the current_user has to have a valid Ultimate license. For self-managed, the ai_tanuki_bot feature has be available (note that this feature is experimental and will also need an embedding database for self-managed).

How to set up and validate locally

  1. Ensure the embedding database is set up: !118156 (merged)
  2. Enable checks: Feature.enable(:openai_experimentation), Feature.enable(:tanuki_bot)
  3. Invoke a mutation as shown above
  4. Tail the logs for the response, or set a breakpoint in https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/app/graphql/ee/graphql_triggers.rb#L8 to see the response

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Terri Chu

Merge request reports