Added the new "Comment Temperature" AI feature

What does this MR do and why?

This merge request introduces a new feature called "Measure Comment Temperature" to the GitLab Enterprise Edition (EE). This feature allows users to gauge the sentiment of comments, helping maintain a healthy and productive discussion environment. It's powered by AI and can be enabled via a feature flag. Additionally, the code includes updates to policies, services, and configuration files to support this new functionality.

The MR adds the new "Comment Temperature" feature as presented in the video below. The feature allows users to gauge the sentiment of comments, helping maintain a healthy and productive discussion environment

BE changes:

  • A new Feature Flag :comment_temperature
  • A new unit primitive (measure_comment_temperature) support. The UP configuration has been merged into the Cloud Connector earlier
  • New AI feature (measure_comment_temperature) registered in the catalog
  • New AiActionInput type (measureCommentTemperature)
  • New user ability (:measure_comment_temperature). The ability is added to the issuable and epic policies to cover Epics, Issues, and Merge Requests.

FE changes:

Will come as a next step.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Video: Screenshot_2024-12-07_at_01.46.00

How to set up and validate locally

With the feature flag OFF

  1. In your GDK instance, go to GraphQL explorer (<YOUR_GDK_URL>/-/graphql-explorer)
  2. Add the following mutation into the editor:
mutation AiAction($input: AiActionInput!) {
  aiAction(input: $input) {
    errors
    clientMutationId
  }
}
  1. Add variables to the "Variable" window:
{
  "input": {
    "measureCommentTemperature": {
      "resourceId": "gid://gitlab/Issue/64",
      "content": "It does not make sense. I think this should be completely re-written"
    }
  }
}

Ensure that the resource you're linking to is part of a project in which you have AI features enabled. If you have the AI features enabled for the Flightjs group in your local GDK, then you could use the following GIDs for testing:

#  Epic: "gid://gitlab/Epic/26"
#  Issue: "gid://gitlab/Issue/64"
#  MR: "gid://gitlab/MergeRequest/31"
  1. Execute the query.
  2. You should get a response similar to:
{
  "data": {
    "aiAction": {
      "errors": [
        "AI features are not enabled or resource is not permitted to be sent."
      ],
      "clientMutationId": null
    }
  },
  "correlationId": "01JEFCHYGS2582BMR46Z6GPJTC"
}

With the feature flag ON

  1. In rails console enable the experiment fully
    Feature.enable(:comment_temperature, User.first)
  2. Execute the same query in GraphQL explorer again
  3. This time, the response should look similar to:
{
  "data": {
    "aiAction": {
      "errors": [],
      "clientMutationId": null
    }
  },
  "correlationId": "01JEFCS3858HW8NZNFZ08K811M"
}
  1. If you check log/llm.log you should see that the two last entries in the log are about sending and receiving a response, initiated by the mutation you've just ran
Edited by Denys Mishunov

Merge request reports

Loading