Adding backend support for summarizing a new merge request
Add backend endpoint for AI summary on a new MR
What does this MR do and why?
This MR adds the backend component for a new AI-powered feature to the merge request creation screen that automatically summarizes the changes in the merge request in a few sentences. This summary will help reviewers quickly understand the purpose and impact of the changes, making the review process more efficient.
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
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Make sure your local AI settings are on! https://docs.gitlab.com/ee/development/ai_features/
- Enable the
:add_ai_summary_for_new_mr
feature flag in the rails console:Feature.enable(:add_ai_summary_for_new_mr)
- Go to your local GraphiQL instance (might be located at https://gdk.test:3443/-/graphql-explorer)
- Get a project ID from one of your local projects
- Find a branch to use as a comparison
- Try to run the following GraphQL query:
mutation {
aiAction(
input: {
summarizeNewMergeRequest: {
resourceId: "gid://gitlab/Project/[PROJECT ID NUMBER]",
sourceBranch: "[COMPARISON BRANCH]"
targetBranch: "main"
}
}
){
requestId
errors
clientMutationId
}
}
- Give a slight smile and nod approvingly.
Changes
- Add a new mutation
summarizeNewMergeRequest
to the GraphQL API. - Add a new service
Llm::SummarizeNewMergeRequestService
to handle the mutation. - Add a new template
Gitlab::Llm::Templates::SummarizeNewMergeRequest
to generate the prompt for the AI model. - Add a new completions worker
Gitlab::Llm::VertexAi::Completions::SummarizeNewMergeRequest
to handle the completion request. - Add a new response modifier
Gitlab::Llm::VertexAi::ResponseModifiers::Predictions
to modify the response from the AI model. - Add a new subscription
Gitlab::Llm::GraphqlSubscriptionResponseService
to publish the response from the AI model to the GraphQL subscription. - Add a new policy
ProjectPolicy#summarize_new_merge_request
to control access to the new feature. - Add a new feature flag
add_ai_summary_for_new_mr
to control the availability of the new feature. - Add a new documentation page to explain the new feature.
Related issues
- Related to #429882 (closed)
This description was generated for revision 84b31900 using AI
Edited by Gary Holtz