delete.mdx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. ---
  2. title: 🗑 delete
  3. ---
  4. ## Delete Document
  5. `delete()` method allows you to delete a document previously added to the app.
  6. ### Usage
  7. ```python
  8. from embedchain import App
  9. app = App()
  10. forbes_doc_id = app.add("https://www.forbes.com/profile/elon-musk")
  11. wiki_doc_id = app.add("https://en.wikipedia.org/wiki/Elon_Musk")
  12. app.delete(forbes_doc_id) # deletes the forbes document
  13. ```
  14. <Note>
  15. If you do not have the document id, you can use `app.db.get()` method to get the document and extract the `hash` key from `metadatas` dictionary object, which serves as the document id.
  16. </Note>
  17. ## Delete Chat Session History
  18. `delete_session_chat_history()` method allows you to delete all previous messages in a chat history.
  19. ### Usage
  20. ```python
  21. from embedchain import App
  22. app = App()
  23. app.add("https://www.forbes.com/profile/elon-musk")
  24. app.chat("What is the net worth of Elon Musk?")
  25. app.delete_session_chat_history()
  26. ```
  27. <Note>
  28. `delete_session_chat_history(session_id="session_1")` method also accepts `session_id` optional param for deleting chat history of a specific session.
  29. It assumes the default session if no `session_id` is provided.
  30. </Note>