piazzatron/anki-smart-notes

Conditions in prompts

Closed this issue · 5 comments

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

  • English word
  • Polish translation
  • English word definition
  • example of use

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:

  • if {{def}} is not an empty field then use prompt numer 1
  • if {{def}} is an empty fields then use prompt numer 2

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.

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.

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?

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 :)

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