Open mathijsvdv opened 10 months ago
Just implemented caching upon card review using a JSON file:
min_cards=5
. It then asks for 10 more cards from OpenAI.Limitations we need to iron out:
min_cards
, the process is blocked for filling the cache even though we actually have a card to show.Here are some possible solutions:
min_cards
, we can fill the cache in the background while we continue to serve cards from the cache
New generated cards need to be shown to a user upon reviewing a card. Since we need to make a request to OpenAI, this can induce significant latency when reviewing cards.
Filling the cache - triggers
We can use multiple strategies to fill the cache. I'll list the pros and cons:
Given these pros and cons, I will consider implementing in the following order:
Preventing card review blocking
Especially when filling the cache upon startup or any other event outside card review, we need any OpenAI calls to be made in the background. Here are two possible solutions to this:
Technology implementation of the cache
Generated cards need to be persisted to disk, because we may not be in the same Anki session the next time we review the card. Anki may have been closed and then reopened.
Persisting to disk means we need to be able to read the cards quickly. This means we can store them in a database. The database is of a size of the same order of magnitude as the cards which the client already has on their local system. To avoid slow network traffic, it makes sense to also store this table locally.