continuedev / continue

⏩ Continue is the leading open-source AI code assistant. You can connect any models and any context to build custom autocomplete and chat experiences inside VS Code and JetBrains
https://docs.continue.dev/
Apache License 2.0
14.93k stars 1.1k forks source link

Slash command not working with Deepseek-v2 and Yi-Large API #1446

Closed mcthesw closed 2 months ago

mcthesw commented 2 months ago

Before submitting your bug report

Relevant environment info

- OS: Windows11 22H2
- Continue: v0.9.155 (pre-release)
- IDE: VSCode 1.90.0
- Model: Yi-large, DeepSeek-V2. Both official online API.

Description

def is_prime(n:int):
    if n == 1:
        return False
    for i in range(2, n):
        if n % i == 0:
            return False
    return True

/comment

Command above will raise an error like this Deepseek-V2: image Yi-large: image

But everything is ok when using Gpt4o image

To reproduce

  1. Setup config
    "models": [
    {
      "model": "deepseek-chat",
      "title": "Deepseek Chat",
      "apiBase": "https://api.deepseek.com/v1",
      "apiKey": "",
      "completionOptions": {
        "temperature": 0
      },
      "provider": "openai"
    },
    {
      "model": "yi-large",
      "apiKey": "",
      "title": "Yi Large",
      "apiBase": "https://api.lingyiwanwu.com/v1",
      "provider": "openai"
    },
    {
      "provider":"openai",
      "apiKey": "",
      "apiBase": "https://my-openai-proxy",
      "title": "Gpt4o",
      "model":"gpt-4o"
    }
    ]
  2. Use slash command like edit and comment (only test works fine)

Log output

when using deepseek-v2:

console.ts:137 [Extension Host] Error handling webview message: {
  "msg": {
    "messageId": "da241e9b-f265-4f61-9185-0bc5b65c149d",
    "messageType": "command/run",
    "data": {
      "input": "/comment .py (9-10)\nif __name__ == '__main__':\r\n   draw_rect(5)\n",
      "history": [
        {
          "role": "user",
          "content": "Take the file prefix and suffix into account, but only rewrite the code_to_edit as specified in the user_request. The code you write in modified_code_to_edit will replace the code between the code_to_edit tags. Do NOT preface your answer or write anything other than code. The </modified_code_to_edit> tag should be written to indicate the end of the modified code section. Do not ever use nested tags.\n\nExample:\n\n<file_prefix>\nclass Database:\n    def __init__(self):\n        self._data = {{}}\n\n    def get(self, key):\n        return self._data[key]\n\n</file_prefix>\n<code_to_edit>\n    def set(self, key, value):\n        self._data[key] = value\n</code_to_edit>\n<file_suffix>\n\n    def clear_all():\n        self._data = {{}}\n</file_suffix>\n<user_request>\nRaise an error if the key already exists.\n</user_request>\n<modified_code_to_edit>\n    def set(self, key, value):\n        if key in self._data:\n            raise KeyError(f\"Key {{key}} already exists\")\n        self._data[key] = value\n</modified_code_to_edit>\n\nMain task:\n\n<file_prefix>\ndef is_prime(n:int):\r\n    if n == 1:\r\n        return False\r\n    for i in range(2, n):\r\n        if n % i == 0:\r\n            return False\r\n    return True\r\n\r\nif __name__ == '__main__':\r\n</file_prefix>\n<code_to_edit>\nif __name__ == '__main__':\r\n   draw_rect(5)\n</code_to_edit>\n<user_request>\n/comment ```f.py (9-10)\nif __name__ == '__main__':\r\n   draw_rect(5)\n```\n</user_request>\n<modified_code_to_edit>\n"
        }
      ],
      "modelTitle": "Deepseek Chat",
      "slashCommandName": "comment",
      "contextItems": [
        {
          "content": "if __name__ == '__main__':\r\n   draw_rect(5)",
          "name": "f.py (9-10)",
          "description": "d:\\Coding\\PythonData\\temp\\f.py",
          "id": {
            "providerTitle": "code",
            "itemId": "d:\\Coding\\PythonData\\temp\\f.py"
          },
          "editing": true
        }
      ],
      "historyIndex": 0,
      "selectedCode": [
        {
          "filepath": "d:\\Coding\\PythonData\\temp\\f.py",
          "range": {
            "start": {
              "line": 8,
              "character": 0
            },
            "end": {
              "line": 9,
              "character": 0
            }
          }
        }
      ]
    }
  }
}

Error: HTTP 404 Not Found from https://api.deepseek.com/v1/completions
mcthesw commented 2 months ago

Thanks to Nate Sesti for providing the solution

This will stop Continue from calling the /v1/completions endpoint instead of /v1/chat/completions, which Deepseek's API does not support unfortunately

{
      "model": "deepseek-chat",
      "title": "Deepseek Chat",
      "apiBase": "https://api.deepseek.com/v1",
      "apiKey": "",
      "completionOptions": {
        "temperature": 0
      },
      "provider": "openai",
      "useLegacyCompletionsEndpoint": false
},