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

Adding path based file exclusions #29

Merged
merged 4 commits into from
Mar 22, 2023
Merged

Adding path based file exclusions #29

merged 4 commits into from
Mar 22, 2023

Conversation

cpaika
Copy link
Contributor

@cpaika cpaika commented Mar 22, 2023

Adds the ability to exclude a path in your Vault with sensitive data from being sent to OpenAI for indexing. Intention is to support users who want this plugin's functionality, but want to keep some files private.

Fixes #20

@@ -238,6 +255,10 @@ export class VectorStore {
}

async addFile(file: TFile) {
if(this.isFileExcluded(file)) {
console.log("Skipping excluded file")
Copy link
Member

Choose a reason for hiding this comment

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

Make this a debug log or remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will just remove

keysToBeDeleted.forEach(k => {
this.embeddings.delete(k)
})
await this.saveEmbeddingsToDatabaseFile() // todo debounce
Copy link
Member

Choose a reason for hiding this comment

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

heh we need to consider this when merging #30 which does the debouncing 😈

src/main.ts Outdated
this.vectorStore.setExclusionPath(this.settings.exclusionPath)
this.vectorStore.deleteByPathPrefix()
const files = this.app.vault.getMarkdownFiles()
this.vectorStore.updateDatabase(files) // TODO trigger re-indexing
Copy link
Member

Choose a reason for hiding this comment

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

whats the todo here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed ty

.onChange(async (value) => this.provisionalExclusionPath = value))
.addButton(button => button.
setButtonText("Set Exclusion")
.onClick(async _ => {
Copy link
Member

Choose a reason for hiding this comment

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

what is the _ i haven't seen this syntax

Copy link
Contributor Author

@cpaika cpaika Mar 22, 2023

Choose a reason for hiding this comment

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

"Drop this variable, dont give it a name". NVM, what I wanted here was ()

}

private isFilePathExcluded(file: string): boolean {
return (!!this.exclusionPath.trim() && file.startsWith(this.exclusionPath))
Copy link
Member

Choose a reason for hiding this comment

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

do you know if its possible for this.exclusionPath to be null/undefined? to be safe, you may want to check that first
this.exclusionPath && !!this.exclusionPath.trim() && file.startsWith(this.exclusionPath)

const keysToBeDeleted: string[] = []
for (const key of this.embeddings.keys()) {
if(this.isFilePathExcluded(key)) {
console.log("Excluded Path:" + key)
Copy link
Member

Choose a reason for hiding this comment

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

Debug log or remove

@cpaika cpaika merged commit 79b0ca2 into main Mar 22, 2023
@kristenbrann kristenbrann deleted the exclusions branch March 22, 2023 23:41
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.

FR: exclude folder or file pattern
2 participants