Skip to content

Add code suggestions models

Jan Provaznik requested to merge jp-cs-prompt into master

What does this MR do and why?

Related to #423522 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

(optional - for testing with AI_gateway) point Rails to use your local AI gateway by setting CODE_SUGGESTIONS_BASE_URL and restart rails-web

$ cat ../env.runit
export GITLAB_SIMULATE_SAAS=1
export CODE_SUGGESTIONS_BASE_URL=http://0.0.0.0:5052

For checking outgoing params, you can log the content of the request passed to workhorse, something like:

diff --git a/ee/lib/api/code_suggestions.rb b/ee/lib/api/code_suggestions.rb
index 0a07dbedec23..ec5f07586362 100644
--- a/ee/lib/api/code_suggestions.rb
+++ b/ee/lib/api/code_suggestions.rb
@@ -117,6 +118,7 @@ def gitlab_realm
             params: params.except(:private_token)
           )
 
+          Rails.logger.error model.body
           workhorse_headers =
             Gitlab::Workhorse.send_url(
               model.endpoint,

and then check with curl request that the outgoing request contains prompt and prompt_version params.

curl --header "PRIVATE-TOKEN: xyz" -d 'current_file[file_name]=test.py&current_file[content_above_cursor]=// GitLab Duo Generate: write hello world function &current_file[content_below_cursor]=aaaa' --request POST http://192.168.1.8:3000/api/v4/code_suggestions/completions

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