I am implementing a version history feature in my application, and the basic feature of…
- User
I am implementing a version history feature in my application, and the basic feature of my application is writing documents (Like google docs). So, to manage auto-saved versions, I need a small algorithm/equation, of when to save an auto-saved version.
I don't know how other applications are maintaining the auto saved version, like google docx, notion, WordPress, and others but I am thinking to manage it based on my last manually saved version, last auto saved version and difference of words between last current document. can you please help me how can I manage my auto saved version efficiently? you can provide examples of others applications how they are managing auto saved version?
Assistant
I think what you’re looking for is an algorithm that can take into account how much the current version of the document has changed since the last auto-saved version, as well as how long it has been since the last auto-saved version. I don’t know how other applications manage this, but I’m guessing that they do something similar to the following:
-
Keep track of the number of words in the document, and save an auto-saved version whenever the number of words changes by a certain percentage (say, 10%) from the previous auto-saved version.
-
Also keep track of the time since the last auto-saved version, and save an auto-saved version whenever a certain amount of time has passed (say, 1 hour).
-
- User
I like the idea, can we improve above algorithim to manage it more efficiently? Instead of using direct count of words and time, I need a more efficient way which can avoid saving a lot auto saved versions by introducing a threshold for word changes and time??
Assistant
Sure, here's a modified algorithm that incorporates thresholds for word changes and time:
-
Keep track of the number of words in the document and the time since the last auto-saved version.
-
When the number of words in the document changes by a certain percentage (e.g., 10%) from the previous auto-saved version, or when a certain amount of time (e.g., 1 hour) has passed since the last auto-saved version, check if the changes exceed a certain threshold.
-
If the changes exceed the threshold, save an auto-saved version of the document. The threshold can be set based on the size of the changes and the time since the last auto-saved version. For example, a higher threshold can be set for larger changes and shorter time intervals, and a lower threshold can be set for smaller changes and longer time intervals.
-
Repeat steps 2-3 until the user manually saves the document or the auto-saved versions exceed a certain limit (e.g., 10 versions).
This algorithm takes into account both the changes made to the document and the time elapsed since the last auto-saved version, and allows you to set thresholds to avoid saving too many auto-saved versions.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.