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

chore(audoedit): decouple codeToReplaceData from getPromptForModelType #6474

Merged
merged 3 commits into from
Dec 27, 2024

Conversation

valerybugakov
Copy link
Member

  • Prepping for the analytics logger integration.
  • No functional changes included.
  • Decouples the codeToReplaceData computation from getPromptForModelType. This is necessary because codeToReplaceData will be used to create the analytics logger request early in the autoedits generation code path. By calculating it independently, we can have it ready earlier in the pipeline.

Test plan

CI + updated unit tests.

Copy link
Contributor

@hitesh-1997 hitesh-1997 left a comment

Choose a reason for hiding this comment

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

Had some doubts regarding the method, added comments.

@@ -155,6 +156,13 @@ export class AutoeditsProvider implements vscode.InlineCompletionItemProvider, v
maxSuffixLength: tokensToChars(autoeditsProviderConfig.tokenLimit.suffixTokens),
})

const { fileWithMarkerPrompt, areaPrompt, codeToReplaceData } = getCurrentFilePromptComponents({
Copy link
Contributor

@hitesh-1997 hitesh-1997 Dec 27, 2024

Choose a reason for hiding this comment

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

Why do we need this decoupling, do autoedits-provider need any additional fields from the codeToReplaceData?

I think fileWithMarkerPrompt and areaPrompt are the prompt components which are used to construct the final prompt. Earlier structure abstracts the individual prompt components from the autoedits-provider so that, autoedits-provider only has to know about the final prompt and not the individual components, and final prompt-strateges (eg: default-prompt-strategy.ts or short-term-diff-prompt-strategy.ts) can call and use these prompt component fileWithMarkerPrompt and integrate/manipulate however it sees fit.

  1. autoedit-provider first receiving the these prompt components, then it sending to the prompt constructors (like default-prompt-strategy) imposes some risk, for example what if the prompt gets modified in the autoedits-provider itself.
  2. Also, this introduces another layer in the final prompt construction, where I need to aware of how the prompt flows in the autoedits-provider as well, where earlier, I could just read prompt-constructor for the final prompt creation and had to not at all look at the autoedits-provider.

I think if we need some additional fields from the prompt constructor we could send them in the codeToReplaceData itself, but can keep the responsibility of creating final prompt with individual prompt constructors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I agree. I started moving fileWithMarkerPrompt, areaPrompt out of getCurrentFilePromptComponents so that we can get only codeToReplaceData and other parts would be calculated inside of the getPromptForModelType method but it involved too many additional changes.

For now, my goal is to extract the codeToReplaceData calculation because it's helpful to have it early. I can hide fileWithMarkerPrompt, areaPrompt from the autoedits provider in a follow-up PR. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah totally, we can do that in a follow up PR.
Approving to unblock !!

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@hitesh-1997 hitesh-1997 left a comment

Choose a reason for hiding this comment

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

We can address the comment in the follow up PR.
Otherwise, looks good to me !!

@valerybugakov valerybugakov merged commit 0ce34ff into main Dec 27, 2024
20 of 21 checks passed
@valerybugakov valerybugakov deleted the vb/autoedits-analytics-logger-integration-2 branch December 27, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants