Add code suggestions models
What does this MR do and why?
Related to #423522 (closed)
- adds basic structure for code suggestion models which allows using different model for different code creation inputs (currently only from comment) - #423522 (comment 1534934962)
- adds
prompt
parameter to code suggestion which wraps original "prefix" in markdown - adds
prompt_version
parameter -1
is used by default,2
for generation endpoint whenprompt
is added (gitlab-org/modelops/applied-ml/code-suggestions/ai-assist#284 (comment 1541997759))
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¤t_file[content_above_cursor]=// GitLab Duo Generate: write hello world function ¤t_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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Jan Provaznik