feat: support additional context in code completions
What does this merge request do and why?
Adds new context
prompt component to v3 code completions endpoint
Example Payload
{
"prompt_version": 3,
"prompt_components": [
{
"type": "code_editor_completion",
"payload": {
"file_name": "main.go",
"language_identifier": "go",
"content_above_cursor": "func parseEnvFile(filename string) (map[string]string, error) {",
"content_below_cursor": "}",
"model_provider": "vertex-ai",
"stream": false,
"model_name": "code-gecko@002"
}
},
{
"type": "code_context",
"payload": {
"content": "import os",
"name": "test",
"type": "function"
}
}
]
}
Resolves #476
How to set up and validate locally
- Add context to the v3 code completions request as
context
prompt components. - In the request sent to code-gecko, notice how the context has been added before the prefix (but after the comment) up to the model window size
Merge request checklist
-
Tests added for new functionality. If not, please raise an issue to follow up. -
Documentation added/updated, if needed.
Closes #476
Edited by Allen Cook