Draft: Add temporary AI endpoint for code suggestions
What does this MR do and why?
Not to be merged.
This supports our work in &10808 (closed) by adding a Rails API endpoint that retrieves code suggestions from the model gateway.
We will use this to test self-managed access to code suggestions through an AI abstraction layer using a JWT issued by CustomersDot.
For testing, invoke this endpoint as follows:
curl -s -H'Authorization: Bearer <LOCAL_PAT>' -H"x-gitlab-ai-token: $(curl -s -H'Authorization: Bearer <SAAS_PAT>' -XPOST https://gitlab.com/api/v4/code_suggestions/tokens | jq -r '.access_token')" -d'{
"prompt_version": 1,
"current_file": {
"file_name": "test.py",
"content_above_cursor": "def is_even(n: int) ->",
"content_below_cursor": ""
}
}' localhost:3000/api/v4/code_suggestions/completions | jq
{
"id": "id",
"model": {
"engine": "codegen",
"name": "ensemble"
},
"object": "text_completion",
"created": 1687778297,
"choices": [
{
"text": " bool:\n\treturn n % 2 == 0",
"index": 0,
"finish_reason": "length"
}
]
}
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
Numbered steps to set up and validate the change are strongly suggested.
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.
Related to #415793 (closed)