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

Hitesh/add diff strategies logging #6189

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

hitesh-1997
Copy link
Contributor

@hitesh-1997 hitesh-1997 commented Nov 25, 2024

change the interface schema for diff calculation to enable logging the metadata from retreivers
Build on top of PR: #6188

Test plan

  1. Check the suggestion events from telemetry to see the updated metadata field.

@hitesh-1997 hitesh-1997 changed the base branch from main to hitesh/diff-structure November 25, 2024 11:28
@beyang beyang changed the title Hitesh/add diff stratagies logging Hitesh/add diff strategies logging Nov 25, 2024
throw new Error(`Unknown diff strategy identifier: ${identifier}`)
}
}
import type { AutocompleteContextSnippetMetadataFields } from '../../../../../../../lib/shared/src/completions/types'

export interface RecentEditsRetrieverDiffStrategy {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a docstring describing the interface contract and what role this plays in the overall process of integrating recent low-level edits into a more coherent history of recent edits? My rough understanding is that this takes a low-level or line-by-line diff and outputs a set of larger edits that serve as better context for LLM consumption, but how that's done and what other components are involved is a bit unclear. Also, what does the metadata method return and how is that expected to be useful in the aforementioned pipeline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure @beyang
Added the documentation for the interface. Also added a comment stating what we consider as a logical change.
To make sure the data is correct, I sampled the diff examples from different strategies which I manually analysed. Also adding a link here for reference.

Base automatically changed from hitesh/diff-structure to main November 25, 2024 21:37
@hitesh-1997 hitesh-1997 force-pushed the hitesh/add-diff-stratagies-logging branch from 251ffc7 to 717cb79 Compare November 25, 2024 21:43
*/
recentEditsRetrieverDiffStrategy?: string
diffStrategyMetadata?: AutocompleteContextSnippetMetadataFields
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to name the type in the same way?

Suggested change
diffStrategyMetadata?: AutocompleteContextSnippetMetadataFields
diffStrategyMetadata?: AutocompleteDiffStrategyMetadata

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing,
Since This field is intended to capture additional metadata from the context retrievers and not limited by diff retriever. Changed the name to retrieverMetadata

@@ -1,48 +1,34 @@
import type { PromptString } from '@sourcegraph/cody-shared'
import type * as vscode from 'vscode'
import { AutoeditWithShortTermDiffStrategy } from './auotedit-short-term-diff'
import { UnifiedDiffStrategy } from './unified-diff'
import type { AutocompleteContextSnippetMetadataFields } from '../../../../../../../lib/shared/src/completions/types'
Copy link
Member

Choose a reason for hiding this comment

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

We should use @sourcegraph/cody-shared to import from lib/shared. AutocompleteContextSnippetMetadataFields import should be added to the existing cody-shared import statement.

To make AutocompleteContextSnippetMetadataFields available to the outside world, it should be added to lib/shared/src/index.ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing this,
I use this extension which automatically add imports for the variables I copy, guess it doesn't consider this.
Fixed at all the places.

@@ -1,4 +1,5 @@
import { PromptString } from '@sourcegraph/cody-shared'
import type { AutocompleteContextSnippetMetadataFields } from '../../../../../../../lib/shared/src/completions/types'
Copy link
Member

Choose a reason for hiding this comment

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

Let's update all the other AutocompleteContextSnippetMetadataFields imports in the same way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

diffStrategyIdentifier: RecentEditsRetrieverDiffStrategyIdentifier.UnifiedDiff,
diffStrategyList: [new UnifiedDiffStrategy({ addLineNumbers: false })],
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to address this now, but should we remove supercompletion-related code from the codebase? @hitesh-1997 @beyang. We can always check it back in, but we won't need to maintain it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should be okay I think with me !!

@hitesh-1997 hitesh-1997 merged commit 3f0812c into main Nov 26, 2024
19 of 20 checks passed
@hitesh-1997 hitesh-1997 deleted the hitesh/add-diff-stratagies-logging branch November 26, 2024 12:24
hitesh-1997 added a commit that referenced this pull request Nov 26, 2024
## Context
Add diff strategies for diff calculation 
Build on top of PR: #6189

## Test plan
Added CI tests
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.

3 participants