Skip to content

AI Code Suggestions - Monolith API

Max Woolf requested to merge mw/code-suggestions/authentication-tokens into master

What does this MR do and why?

  • Adds a new REST API endpoint: POST /code_suggestions/completions to provide code suggestions using code-gecko.

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/415581

Screenshots or screen recordings

Screencast (Private): https://www.youtube.com/watch?v=vMisEcxkNhM

How to set up and validate locally

  • Enable SaaS simulation on your GDK.

  • Enable the following feature flags: :ai_assist_api, :code_suggestions_tokens_api

  • Generate an access token using a PAT:

    POST /api/v4/code_suggestions/tokens
  • Generate a code suggestion (here's an example call):

POST /api/v4/code_suggestions/completions

Authorization: Bearer {ACCESS_TOKEN}
X-Gitlab-Authentication-Type: oidc
{"prompt_version":"1","current_file":{"file_name":"dog.js","content_above_cursor":"class Car:\n def init(self, make, model, year, color):\n self.make = make\n self.model = model\n self.year = year\n self.color = color\n self.is_running = False\n self.speed = 0\n \n def start(self):\n if not self.is_running:\n self.is_running = True\n print("The car is now running.")\n else:\n print("The car is already running.")\n \n def stop(self):\n if self.is_running:\n self.is_running = False\n self.speed = 0\n print("The car has stopped.")\n else:\n print("The car is already stopped.")\n \n def accelerate(self, increment):","content_below_cursor":""},"project_id":"23"} 
  • Evaluate that the response is the same response given by the model gateway. This API should be a drop-in replacement.

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 Jan Provaznik

Merge request reports