Code Suggestions development guidelines
Code Suggestions development setup
The recommended setup for locally developing and debugging Code Suggestions is to have all 3 different components running:
- IDE Extension (e.g. VS Code Extension).
- Main application configured correctly (e.g. GDK).
- AI Gateway.
This should enable everyone to see locally any change in an IDE being sent to the main application transformed to a prompt which is then sent to the respective model.
Setup instructions
- Install and run locally the VS Code Extension:
- Add the
"gitlab.debug": true
info to the Code Suggestions development config:- In VS Code, go to the Extensions page and find “GitLab Workflow” in the list.
- Open the extension settings by clicking a small cog icon and select “Extension Settings” option.
- Check a “GitLab: Debug” checkbox.
- If you’d like to test code suggestions are working from inside the VS Code Extension, then follow the steps to set up a personal access token with your GDK inside the new window of VS Code that pops up when you run the “Run and Debug” command.
- Once you complete the steps below, to test you are hitting your local
/code_suggestions/completions
endpoint and not production, follow these steps:- Inside the new window, in the built in terminal select the “Output” tab then “GitLab Language Server” from the drop down menu on the right.
- Open a new file inside of this VS Code window and begin typing to see code suggestions in action.
- You will see completion request URLs being fetched that match the Git remote URL for your GDK.
- Once you complete the steps below, to test you are hitting your local
- Add the
- Main Application (GDK):
- Install the GitLab Development Kit.
- Enable Feature Flag
ai_duo_code_suggestions_switch
:- In your terminal, go to your
gitlab-development-kit
>gitlab
directory. - Run
gdk rails console
orbundle exec rails c
to start a Rails console. -
Enable the Feature Flag for the code suggestions tokens API by calling
Feature.enable(:ai_duo_code_suggestions_switch)
from the console.
- In your terminal, go to your
- Setup AI Gateway.
- Run your GDK server with
gdk start
if it’s not already running.
Setup instructions to use staging AI Gateway
When testing interactions with the AI Gateway, you might want to integrate your local GDK with the deployed staging AI Gateway. To do this:
- You need a cloud staging license that has the Code Suggestions add-on,
because add-ons are enabled on staging. Drop a note in the
#s_fulfillment
ors_fulfillment_engineering
internal Slack channel to request an add-on to your license. See this handbook page for how to request a license for local development. -
Set environment variables to point customers-dot to staging, and the AI Gateway to staging:
export GITLAB_LICENSE_MODE=test export CUSTOMER_PORTAL_URL=https://customers.staging.gitlab.com export AI_GATEWAY_URL=https://cloud.staging.gitlab.com/ai
- Restart the GDK.
- Ensure you followed the necessary steps to enable the Code Suggestions feature.
- Test out the Code Suggestions feature by opening the Web IDE for a project.
Setup instructions to use GDK with the Code Suggestions Add-on
-
Add a GitLab Ultimate Self-Managed subscription with a Duo Pro subscription add-on to your GDK instance.
- Sign in to the staging Customers Portal by selecting the Continue with GitLab.com account button. If you do not have an existing account, you are prompted to create one.
- If you do not have an existing cloud activation code, visit the Ultimate Self-Managed Subscription page using the buy subscription flow link.
- Purchase the subscription using a test credit card.
- Once you have a subscription, on the subscription card, select the ellipse menu … > Buy Duo Pro add-on.
- Use the previously saved credit card information, and the same number of seats as in the subscription.
After this step is complete, you will have an activation code for a GitLab Ultimate Self-Managed subscription with a Duo Pro add-on.
-
Follow the activation instructions:
-
Set environment variables.
export GITLAB_LICENSE_MODE=test export CUSTOMER_PORTAL_URL=https://customers.staging.gitlab.com export GITLAB_SIMULATE_SAAS=0
On a non-GDK instance, you can set the variables using
gitlab_rails['env']
in thegitlab.rb
file. 1. Restart your GDK. 1. Go to/admin/subscription
. 1. Optional. Remove any active license. 1. Add the new activation code. -
- Inside your GDK, navigate to Admin area > GitLab Duo Pro, go to
/admin/code_suggestions
- Filter users to find
root
and click the toggle to assign a GitLab Duo Pro add-on seat to the root user
Setup instructions to use the Duo Pro add-on with a staging GitLab.com account
- Have your account ready at https://staging.gitlab.com
- Create a new group or use an existing one as the namespace which will receive the Duo Pro access
- Navigate to
Settings > Billing
- Initiate the purchase flow for the Ultimate plan by clicking on
Upgrade to Ultimate
- After being redirected to https://customers.staging.gitlab.com, click on
Continue with your Gitlab.com account
- Purchase the SaaS Ultimate subscription using a test credit card
- Find the newly purchased subscription card, and select from the three dots menu the option
Buy GitLab Duo Pro
- Purchase the GitLab Duo Pro add-on using the same test credit card from the above steps
- Go back to https://staging.gitlab.com and verify that your group has access to Duo Pro by navigating to
Settings > GitLab Duo
and managing seats