piazzatron / anki-smart-notes

Superchange your anki flashcards with ✨AI✨
GNU General Public License v3.0
17 stars 3 forks source link

Conditions in prompts #19

Closed kacperpaluch closed 2 months ago

kacperpaluch commented 2 months ago

I use Anki Smart Notes to add examples of vocabulary usage in English. My collection consists of several fields:

I created a prompt: I'm learning English. I will give you a word in that language, its definition and its translation into Polish. Write 3 examples of usage for me. English word: {{ang}} Definition: {{def}} Polish translation: {{pol1}}

However, there is a problem - I do not have a definition for all the words. If the field {{def}} is empty then unfortunately, but it is not possible to create a usage example - ChatGPT does not answer my question many times. Is it possible to create some conditions? For example:

piazzatron commented 2 months ago

Fun one! For a short term fix, I wonder if you could get away with not including definition in the prompt at all? I would expect ChatGPT to know the polish translation of {{ang}} already.

Thinking further out, rather than build some confusing conditional syntax into SmartNotes, I'd probably leave it to ChatGPT: so you can have a prompt like I"m going to provide you two words, X {{X}} and Y {{Y}}. If X doesn't exist, respond with ..., if Y doesn't exist respond with .... This won't work right now because I have code to skip generating a prompt if a required field is missing, so I'd need to include an additional option to run the prompt even if some fields are missing.

kacperpaluch commented 2 months ago

I know :) I currently use an English word and a Polish translation, with no additional definition, and it works quite OK. Sometimes, especially with words that have several meanings, the definition made the examples a bit better, but even without that it is very good.

piazzatron commented 2 months ago

Gotcha, that makes sense. I'll add an option to generate the smart field even if the referenced fields are empty.

BTW, were you able to get on v1.4.2 to fix that startup crash you were experiencing?

kacperpaluch commented 2 months ago

Gotcha, that makes sense. I'll add an option to generate the smart field even if the referenced fields are empty.

BTW, were you able to get on v1.4.2 to fix that startup crash you were experiencing?

1.4.2 works fine :)

piazzatron commented 2 months ago

Fixed this for real in v1.5.0, prompts with multiple fields can now reference empty fields. Feel free to reopen if you're still having issues