-
Notifications
You must be signed in to change notification settings - Fork 574
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
base: master
Are you sure you want to change the base?
Conversation
|
return output.join('') | ||
} | ||
|
||
export function extractSuffixCellsContext( |
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.
sure seems similar to the above function, can it be deduplicated?
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.
Yes, I'll try to clean it up -- the main difference is which direction to shorten.
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:

…mpletion in a Jupyter notebook
8ca009c
to
5f29d4a
Compare
Will consolidate the function doing the suffix and prefix context fetching. |
…mpletion in a Jupyter notebook
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.
Solution
The
extractContextForCodeWhisperer
function 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/x
branches will not be squash-merged at release time.