Skip to content

Feature/Complete functionality to delete documents#7

Open
psbhatbvbcs wants to merge 4 commits into
Nutlope:mainfrom
psbhatbvbcs:feature/deleteDocuments
Open

Feature/Complete functionality to delete documents#7
psbhatbvbcs wants to merge 4 commits into
Nutlope:mainfrom
psbhatbvbcs:feature/deleteDocuments

Conversation

@psbhatbvbcs

@psbhatbvbcs psbhatbvbcs commented Jan 26, 2024

Copy link
Copy Markdown

Fixes #4 : Unable to delete documents

Hey @jacoblee93 and @Nutlope ! Amazing project.

Summary:

  • This feature successfully handles deletion of documents completely.
  • I have made sure to add functionality such that the document is also deleted from BYTESCALE cloud where the pdf was being stored.
  • It also deletes the record from the Prism-Postgres database.
  • The document list also dynamically updates after deletion.
  • Everything is pretty much dynamic for scaling

NOTE:

  • For this feature to work I had to add an additional .env variable from BYTESCALE. As the current Bytescale key was a public api key it had limited permissions and couldn't delete files.
  • Add the below variable to the .env file:
    NEXT_SECRET_BYTESCALE_API_KEY=

This key can be found in: Bytescale Dashboard > Security > API keys > Secret.

I plan to make regular contributions on the project if I am welcome!
Thank you! And hope you find my feature helpful. 😄

@vercel

vercel Bot commented Jan 26, 2024

Copy link
Copy Markdown

@psbhatbvbcs is attempting to deploy a commit to the Hassanteam Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Jan 26, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pdftochat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 26, 2024 7:55am

Comment thread app/api/chat/route.ts Outdated
),
).toString('base64');

// add a chat thing to prisma

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yup. Removed in the new commit


interface DeleteFileParams {
accountId: string;
apiKey: string;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this need to be a parameter?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I followed the docs of bytescale to implement functionality so I just added this to resolve typescript errors. The Api key is taken from the env variables and then passed to this. Can be removed but i though of keeping the same syntax as docs.

Comment thread app/dashboard/dashboard-client.tsx Outdated
console.log(data.error);
} else {
console.log('Document deleted successfully');
updateDocsList(docsList.filter((doc) => doc.id !== id));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably unnecessary to wrap this? Just call setDocsList directly?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah right. I have done all the requested changes

@jacoblee93

Copy link
Copy Markdown
Collaborator

I think logic looks good! @Nutlope would be better to weigh in on the frontend UX and design.

@psbhatbvbcs

Copy link
Copy Markdown
Author

@jacoblee93 I have done all the requested changes! Thanks for bringing them into light

@Eric013

Eric013 commented Feb 3, 2024

Copy link
Copy Markdown

Hello,

@jacoblee93 To complete the deletion of a document, shouldn't the vectors created in pinecone also be deleted?
await index.namespace('foo-namespace').deleteAll();
See: https://sdk.pinecone.io/typescript/#md:delete-all-records-in-a-namespace

@jacoblee93

Copy link
Copy Markdown
Collaborator

You are correct, thanks for catching!

@psbhatbvbcs

Copy link
Copy Markdown
Author

Hey @Eric013 !! I though of that too initially, but I had assumed it just created new vectors from 0 when i added new documents. But after checking you were right. Added that functionality too to delete that specific document vectors with its namespace.

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.

Unable to delete uploaded documents

3 participants