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

How to remove or replace a file from the Document? #31

Closed
xbotter opened this issue Aug 26, 2023 · 6 comments
Closed

How to remove or replace a file from the Document? #31

xbotter opened this issue Aug 26, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@xbotter
Copy link
Contributor

xbotter commented Aug 26, 2023

If the file has changed or is no longer needed to be accessed in the current memory.

@dluc
Copy link
Collaborator

dluc commented Aug 28, 2023

Currently there's no API to directly edit the content of a document, and we use the ImportDocumentAsync API to refresh the document, passing the original Document ID, re-uploading the document without the file to remove.

We'll improve this area soon :-)

@dluc dluc self-assigned this Aug 28, 2023
@dluc dluc added the enhancement New feature or request label Aug 28, 2023
@dluc
Copy link
Collaborator

dluc commented Aug 29, 2023

We added the ability to delete documents. It doesn't fully address your question but it might help if you put one file per document.

@xbotter
Copy link
Contributor Author

xbotter commented Aug 30, 2023

In my use case, I am trying to use Document as a knowledge database that can be managed in the form of maintaining files.
This requires performing operations to add, delete, and replace files in the Document.

I wonder if this scenario can be supported from semantic memory or if there are better practical methods available?

@dluc
Copy link
Collaborator

dluc commented Aug 30, 2023

@xbotter have you considere using tags and filters?

E.g. rather than multiple files in the one document, uploading multiple documents with the same tag:

var knowledgeBase1 = "001":
var knowledgeBase2 = "ABC":

await memory.ImportDocumentAsync(new Document()
            .AddFile("file1.pdf").AddTag("KnowledgeBase", knowledgeBase1));

await memory.ImportDocumentAsync(new Document()
            .AddFile("file2.pdf").AddTag("KnowledgeBase", knowledgeBase1));

await memory.ImportDocumentAsync(new Document()
            .AddFile("file3.pdf").AddTag("KnowledgeBase", knowledgeBase1));

await memory.ImportDocumentAsync(new Document()
            .AddFile("foobar.docx").AddTag("KnowledgeBase", knowledgeBase2));

var answer = await memory.AskAsync(question, 
                                   MemoryFilters.ByTag("KnowledgeBase", knowledgeBase1));

@xbotter
Copy link
Contributor Author

xbotter commented Aug 31, 2023

Thanks @dluc , I have successfully fulfilled my use case based on your suggestions and reference documents.

@xbotter xbotter closed this as completed Aug 31, 2023
@xbotter
Copy link
Contributor Author

xbotter commented Aug 31, 2023

We added the ability to delete documents. It doesn't fully address your question but it might help if you put one file per document.

Delete and then re-upload, it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants