continue icon indicating copy to clipboard operation
continue copied to clipboard

Cannot read properties of undefined (reading 'trim')

Open giancarlosisasi opened this issue 10 months ago • 1 comments

Before submitting your bug report

Relevant environment info

- OS: macOS 12.5.1 
- Continue: 0.8.23
- IDE: Vscode
- Model: codellama-7b

Description

I have configured Continue to use a local model with Ollama (codellama-7b)

{
  "models": [
    {
      "title": "Ollama-codellama",
      "provider": "ollama",
      "model": "codellama-7b",
      "completionOptions": {}
    },
}

When trying to translate a text to spanish or portuguese with this prompt "/edit translate the selection to spanish" I get the following error:

Cannot read properties of undefined (reading 'trim')

image

In the logs I can see a "too many files" maybe it's because Continues can't index all the files of the current project? 🤔 . My project is a frontend react monorepo with >20k files.

To reproduce

  1. Install Ollama and run in terminal: ollama run codellama:7b
  2. Configure a local model using:
{
  "models": [
    {
      "title": "Ollama-codellama",
      "provider": "ollama",
      "model": "codellama-7b",
      "completionOptions": {}
    },
}
  1. create a file localeSpanish.tsx with the content:
const es = {
  'page-key': {
    WELCOME: 'Welcome',
  },
};

export default es;
  1. Select the "Welcome" string and tell to Continue to translate to spanish using this prompt: "/edit Translate the selected string to spanish"
  2. Press enter

Log output

[Extension Host] Unable to load language for file /Users/user/Documents/my-project/localeSpanish.tsx Error: EMFILE: too many open files, open '/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/tree-sitter-wasms/tree-sitter-tsx.wasm'
	at Object.openSync (node:fs:605:3)
	at Object.func [as openSync] (node:electron/js2c/node_init:2:2214)
	at Object.readFileSync (node:fs:473:35)
	at t.readFileSync (node:electron/js2c/node_init:2:9771)
	at Language.load (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:31235:45)
	at getLanguageForFile (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:31454:45)
	at async getParserForFile (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:31434:22)
	at async getAst (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:188250:18)
	at async getDefinitionsFromLsp (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:189373:15)
	at async getTabCompletion (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:189067:24)
	at async _CompletionProvider.provideInlineCompletionItems (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:189299:27)
	at async ContinueCompletionProvider.provideInlineCompletionItems (/Users/user/.vscode/extensions/continue.continue-0.8.23-darwin-arm64/out/extension.js:189511:27)
	at async U.provideInlineCompletions (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:152:108044)
 Error handling webview message: {
  "msg": {
    "messageId": "bde35118-5cbf-424f-aca8-2d3ec7e684ed",
    "messageType": "command/run",
    "data": {
      "input": "/edit ```localeSpanish.tsx (3-3)\nWelcome\n```\nTranslate the selected string to spanish",
      "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>\nconst en = {\n  'page-key': {\n    WELCOME: 'Welcome',\n</file_prefix>\n<code_to_edit>\nWelcome\n</code_to_edit>\n<file_suffix>\n  },\n};\n\n</file_suffix>\n<user_request>\nTranslate the selected string to spanish\n</user_request>\n<modified_code_to_edit>\n"
        }
      ],
      "modelTitle": "Ollama-codellama",
      "slashCommandName": "edit",
      "contextItems": [
        {
          "content": "Welcome",
          "name": "localeSpanish.tsx (3-3)",
          "description": "/Users/user/Documents/my-project/localeSpanish.tsx",
          "id": {
            "providerTitle": "code",
            "itemId": "/Users/user/Documents/my-project/localeSpanish.tsx"
          },
          "editing": true
        }
      ],
      "historyIndex": 0,
      "selectedCode": [
        {
          "filepath": "/Users/user/Documents/my-project/localeSpanish.tsx",
          "range": {
            "start": {
              "line": 2,
              "character": 0
            },
            "end": {
              "line": 2,
              "character": 0
            }
          }
        }
      ]
    }
  }
}

giancarlosisasi avatar Apr 12 '24 17:04 giancarlosisasi

I'm also getting this bug.

Relevant environment info:

- OS: Windows 11
- Continue: v0.8.23
- IDE: VSCode
- Model: DeepSeek:33b

I can provide logs if desired?

isaacolsen94 avatar Apr 12 '24 20:04 isaacolsen94

It looks like this bug is solved in the current release. I'm going to close the issue, but don't hesitate to re-open if needed

sestinj avatar May 23 '24 01:05 sestinj

Experiencing this on version 0.8.45

image

Cheizr avatar Aug 08 '24 23:08 Cheizr

same

zackify avatar Aug 10 '24 00:08 zackify