Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete context improvement for codestral and qwen coder #3927

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ferenci84
Copy link
Contributor

@ferenci84 ferenci84 commented Feb 1, 2025

Description

Enhance context inclusion for codestral and qwen coder.

Changes:

  1. RecentlyVisitedRangesService from disabled to enabled by default, and numSorroundingLines to 20
  2. In core/autocomplete/templating/filtering.ts moved diff to the back to avoid fill up the prompt leaving no room for other context.
  3. Created the following experimental options to allow contributors and tech-savvy users experiment with enable/disable and change the order of context before someone concludes to a working model:
  // true = enabled, false = disabled, number = enabled with priority
  experimental_includeClipboard: boolean | number;
  experimental_includeRecentlyVisitedRanges: boolean | number;
  experimental_includeRecentlyEditedRanges: boolean | number;
  experimental_includeDiff: boolean | number;
  1. Changed the templates for codestral and Qwen coder to properly include the context in the prompt

Relates to these issues:
#3900 (opened by me as a feature request, however I realized that the feature is already there just not working)
#1952
#3506

(most likely there are more)

Checklist

  • The relevant docs, if any, have been updated or created
  • The relevant tests, if any, have been updated or created

Testing instructions

  1. Run the extension and open the Extension Development Host
  2. Close the bottom panel if it's open (do not open the "Output" tab before the end of the test)
  3. Set up codestral with remote provider and/or qwen coder with ollama as per the instructions of Continue documentation
  4. Add this code into the css test file:
.class1 {
  background-color: red;
}

.class1 .myclass2 { /* I would visit this section last */
  background-color: blue;
}

Add this code to the html test file:

<div class="class1">
    <div class=></div>
  </div>
  1. Run "Developer: Reload Window"
  2. Focus on the css test file somewhere around myclass2
  3. Focus on the html test file after class= and press "
  4. It should autocomplete myclass2

Possible further improvements on this feature:

  • Some code snippets are duplicated. Some logic can be built to resolve overlapping snippets.
  • recentlyVisitedRanges also contain contents from other windows like terminal or output if they are visible. We should handle them separately so that we can control their priority and whether they should be included or not.
  • Limit diff in case there are a lot of changes
  • Test other providers and models

Copy link

netlify bot commented Feb 1, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit d80dbff
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67a460df4132430008254395

Copy link
Contributor Author

@ferenci84 ferenci84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional note: I changed both qwen and codestral template so that they produce a single prompt instead of separate prefix and suffix.
Explanation:
Creating prefix and suffix will result in a request that has "prompt" and "suffix" in the request body. However, after all, the model itself has to get a single prompt (because LLM models only have one "prompt" as input), so somewhere in the process, the provided "prompt" and "suffix" parameters will be converted to a single "prompt", but may not in a way we want: in case of codestral it's [SUFFIX]{suffix}[PREFIX]{prefix}, that makes it impossible to put the context before the [PREFIX] and [SUFFIX] separators. In contrast, providing a single prompt will let us achieve this format: {context}[PREFIX]{prefix}[SUFFIX]{suffix}

Update: I found that this change is conceptually wrong, I updated the PR to contain only minimal changes to the template. With other modifications it's working quite well already.

Current changes in the codestral template:

  • Now it uses relative instead of absolute file paths in the context
  • Added "++++" as a stop word because this is used in the prompt to mark new files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants