-
Notifications
You must be signed in to change notification settings - Fork 747
fix(amazonq): Previous and subsequent cells are used as context for completion in a Jupyter notebook #7086
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
Conversation
|
justinmk3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is helpful, thanks! Tests for this function are here:
aws-toolkit-vscode/packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts
Line 32 in d457022
| describe('extractContextForCodeWhisperer', function () { |
You can run that test file by opening it in vscode then choose Extension tests (current file) (amazon) in the run/debug menu:
8ca009c to
5f29d4a
Compare
|
Will consolidate the function doing the suffix and prefix context fetching. |
5b7ca22 to
76e096a
Compare
packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts
Outdated
Show resolved
Hide resolved
packages/amazonq/test/unit/codewhisperer/util/editorContext.test.ts
Outdated
Show resolved
Hide resolved
6fc5a9f to
db49f5d
Compare
|
lint failure |
130c19d to
2650145
Compare
|
|
||
| const languageCommentChars: Record<string, string> = { | ||
| python: '# ', | ||
| java: '// ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this. It's not sustainable for us to introduce yet another language-specific handling just for notebooks. Why isn't the notebook logic using the existing logic used by other Q functionality ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! I'm new to this codebase, so I'll have to research what existing logic you are referring to -- any quick pointers of where to start looking are appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, Q to the rescue -- figured out the changes I needed to make to runtimeLanguageContext.
2650145 to
a6625ea
Compare
…mpletion in a Jupyter notebook
…mpletion in a Jupyter notebook
Renaming `extractCellsSliceContext` to `getNotebookCellsSliceContext` Co-authored-by: Justin M. Keyes <[email protected]>
a6625ea to
dbfe86b
Compare
## Problem Support of inline completion in JL Notebook is gone since the language server migration. aws/aws-toolkit-vscode#7086 ## Solution Let the IDE provide the file context. There is a technical limitations of the language server that it cannot find or construct the `vscode.NotebookDocument`, `vscode.NotebookCell`. The `workspace.getTextDocument` does not work with JL Notebook as it gets a URI in the format of "`vscode-notebook-cell:/../A1.ipynb#W2sZmlsZQ%3D%3D`". The language server does not have the cell number, cell state, cursor position, etc of the current cell. <!--- REMINDER: - Read CONTRIBUTING.md first. - Add test coverage for your changes. - Link to related issues/commits. - Testing: how did you test your changes? - Screenshots if applicable --> ## License By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Problem
VS Code treats each cell in a notebook as a separate editor. As a result, when building the left- and right-contexts for the completion from the current editor, we were limited to just the current cell, which might be very small and/or reference variables and functions defined in other cells. That meant that completions never used the context of other cells when making suggestions, and were often very generic. #7031
Solution
The
extractContextForCodeWhispererfunction now checks if it is being called in a cell in a Jupyter notebook. If so, it collects the surrounding cells to use as context, respecting the maximum context length. During this process, Markdown cells have each line prefixed with a language-specific comment character.feature/xbranches will not be squash-merged at release time.