Skip to content

Autocomplete: completion is truncated (stops streaming) at the wrong place #3994

Open
@ferenci84

Description

@ferenci84

Before submitting your bug report

Relevant environment info

- OS:
- Continue version: 0.9.260
- IDE version:
- Model: qwen2.5-coder:1.5b-base (ollama)
- config.json:
  
"tabAutocompleteModel": {
    "title": "Qwen2.5-Coder 1.5B",
    "provider": "ollama",
    "model": "qwen2.5-coder:1.5b-base",
    "completionOptions": {
      "maxTokens": 256
    }
  },

The problem

The log shows that the completion is OK, but it only partially appears. The model completes "1__tabAutocompleteModel": { but only "1__ appears.

To reproduce

Open the testing sandbox, add this file:

{
  "1__tabAutocompleteModel": {
    "title": "Codestral",
    "provider": "mistral",
    "model": "codestral-latest",
    "apiKey": "",
    "apiBase": "https://codestral.mistral.ai/v1",
    "completionOptions": {
      "maxTokens": 256
    }
  },

  "tabAutocompleteModel": {
    "title": "Qwen2.5-Coder 3B",
    "provider": "ollama",
    "model": "qwen2.5-coder:1.5b-base",
    "completionOptions": {
      "maxTokens": 256
    }
  },
  "3__tabAutocompleteModel": {
    "title": "Together Qwen2.5 Coder",
    "provider": "together",
    "model": "Qwen/Qwen2.5-Coder-32B-Instruct",
    "apiKey": ""
  }
}

(A bit awkward, but this is a way I switch between different autocomplete model, and this is the place where the error happens)

Save to a file (test_config.json), reload the window. Place the cursor at the empty line and trigger autocomplete with a hotkey.

For me, the completion is:

"2__

In the output, the completion is:

"2__tabAutocompleteModel": {<|cursor|>
}

What causes the problem

I debugged, and found that the problem is caused by this line in core/autocomplete/filtering/streamTransforms/StreamTransformPipeline.ts:

    charGenerator = stopAtStartOf(charGenerator, suffix);

It's reasonable to stop streaming at the start of the suffix, however it seems this doesn't work right, because where it stops is not equal to the start of the suffix.

Log output

==========================================================================
==========================================================================
##### Completion options #####
{
  "contextLength": 8096,
  "maxTokens": 256,
  "model": "qwen2.5-coder:1.5b-base",
  "temperature": 0.01,
  "stop": [
    "<|endoftext|>",
    "<|fim_prefix|>",
    "<|fim_middle|>",
    "<|fim_suffix|>",
    "<|fim_pad|>",
    "<|repo_name|>",
    "<|file_sep|>",
    "<|im_start|>",
    "<|im_end|>",
    "/src/",
    "#- coding: utf-8",
    "```"
  ]
}

##### Prompt #####
Prefix: 
// test_config.json
{
  "1__tabAutocompleteModel": {
    "title": "Codestral",
    "provider": "mistral",
    "model": "codestral-latest",
    "apiKey": "",
    "apiBase": "https://codestral.mistral.ai/v1",
    "completionOptions": {
      "maxTokens": 256
    }
  },
  
Suffix: 
  "tabAutocompleteModel": {
    "title": "Qwen2.5-Coder 3B",
    "provider": "ollama",
    "model": "qwen2.5-coder:1.5b-base",
    "completionOptions": {
      "maxTokens": 256
    }
  },
  "3__tabAutocompleteModel": {
    "title": "Together Qwen2.5 Coder",
    "provider": "together",
    "model": "Qwen/Qwen2.5-Coder-32B-Instruct",
    "apiKey": ""
  }
}
==========================================================================
==========================================================================
Completion:
"2__tabAutocompleteModel": {<|cursor|>
}

Metadata

Metadata

Labels

area:autocompleteRelates to the auto complete featurekind:bugIndicates an unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions