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

Feature/Complete functionality to delete documents #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

psbhatbvbcs
Copy link

@psbhatbvbcs psbhatbvbcs commented Jan 26, 2024

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. 😄

Copy link

vercel bot commented Jan 26, 2024

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

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Jan 26, 2024

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

@@ -170,6 +170,8 @@ export async function POST(req: NextRequest) {
),
).toString('base64');

// add a chat thing to prisma
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove

Copy link
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
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
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.

console.log(data.error);
} else {
console.log('Document deleted successfully');
updateDocsList(docsList.filter((doc) => doc.id !== id));
Copy link
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
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
Collaborator

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

@psbhatbvbcs
Copy link
Author

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

@Eric013
Copy link

Eric013 commented Feb 3, 2024

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
Collaborator

You are correct, thanks for catching!

@psbhatbvbcs
Copy link
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