Skip to content

feat: add code context support to non-vertex code completion

Allen Cook requested to merge acook/mistralai_litellm_context into main

What does this merge request do and why?

Adds code context support to the CodeCompletions class, similar to how it was added to CodeCompletionsLegacy earlier

How to set up and validate locally

Have the AIGW_MODEL_KEYS__MISTRAL_API_KEY setup in your AI Gateway .env file, you can get a free trial at https://mistral.ai/

curl -X "POST" "http://gdk.test:5052/v2/code/completions" \
     -H 'Content-Type: application/json; charset=utf-8' \
 \
     -d $'{
  "current_file": {
    "content_below_cursor": "}",
    "file_name": "main.go",
    "language_identifier": "go",
    "content_above_cursor": "func parseEnvFile(filename string) (map[string]string, error) {"
  },
  "model_name": "codestral",
  "prompt": "func parseEnvFile(filename string)",
  "telemetry": [],
  "context": [
    {
      "content": "import os\\\\n\\\\tf, err := os.Open(filename)\\\\n\\\\tif err != nil {\\\\n\\\\t\\\\treturn nil, err\\\\n\\\\n\\\\t",
      "name": "test",
      "type": "function"
    }
  ],
  "model_provider": "codestral",
  "prompt_version": 2
}'

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.
Edited by Allen Cook

Merge request reports

Loading