refactor: use Prompt Registry for code generation
Relates to issue #1725
Changes
This MR refactors code generation to use the Prompt Registry when there is no prompt id, which is a legacy case (pre-Oct. 2024). This legacy path was using Claude Sonnet v3.5 (anthropic) or Code Bison (vertex-ai) before, so it's unlikely anyone was actually using this. This is simply to support removing legacy code
How to Verify
# Default case (vertex)
curl -X "POST" "http://localhost:5052/v3/code/completions" \
-H 'X-Gitlab-Global-User-Id: test_id' \
-H 'X-Gitlab-Model-Prompt-Cache-Enabled: true' \
-H 'X-gitlab-Realm: SM' \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Cookie: BetterErrors-2.10.1-CSRF-Token=759b9551-abff-4559-a2d7-336c212b0d4e' \
-d $'{
"prompt_components": [
{
"type": "code_editor_generation",
"payload": {
"language_identifier": "go",
"file_name": "test",
"content_below_cursor": "\\n}",
"content_above_cursor": "func hello_world(){\\n\\t"
}
}
]
}'
# Anthropic specified case
## local AIGW completion v3
curl -X "POST" "http://localhost:5052/v3/code/completions" \
-H 'X-Gitlab-Global-User-Id: test_id' \
-H 'X-Gitlab-Model-Prompt-Cache-Enabled: true' \
-H 'X-gitlab-Realm: SM' \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Cookie: BetterErrors-2.10.1-CSRF-Token=759b9551-abff-4559-a2d7-336c212b0d4e' \
-d $'{
"prompt_components": [
{
"type": "code_editor_generation",
"payload": {
"language_identifier": "go",
"model_provider": "anthropic",
"file_name": "test",
"content_below_cursor": "\\n}",
"content_above_cursor": "func hello_world(){\\n\\t"
}
}
]
}'
# Vertex specified case
## local AIGW completion v3
curl -X "POST" "http://localhost:5052/v3/code/completions" \
-H 'X-Gitlab-Global-User-Id: test_id' \
-H 'X-Gitlab-Model-Prompt-Cache-Enabled: true' \
-H 'X-gitlab-Realm: SM' \
-H 'Content-Type: application/json; charset=utf-8' \
-H 'Cookie: BetterErrors-2.10.1-CSRF-Token=759b9551-abff-4559-a2d7-336c212b0d4e' \
-d $'{
"prompt_components": [
{
"type": "code_editor_generation",
"payload": {
"language_identifier": "go",
"model_provider": "vertex-ai",
"file_name": "test",
"content_below_cursor": "\\n}",
"content_above_cursor": "func hello_world(){\\n\\t"
}
}
]
}'
Edited by Allen Cook