[Feature Request] Instruct template automatic substitution
bafterfor opened this issue · comments
It would be convenient for testing different instruct models in a single session, where if you select a different template, it would search and replace the prefixes/suffixes in the current session.
That's not a bad idea, but you can use {inst}
/{/inst}
instead so that the template automatically changes the way you want it to. A big drawback is that to get a prompt 100% correct you would have to write everything on the same line, but I guess it would be worth trying to optionally make the prompt templates more forgiving for cases like this.
It'd probably be a good idea (not to mention relatively simple) to remove all whitespace between the suffix I forgot how my own code works. Anyways, removing all whitespace before {/inst}
and the following prefix {inst}
. That way you can have as many linebreaks as you want inbetween.{inst}
is something we could do.
Also maybe a toggle in the instruct modal to make chat mode append the placeholders instead of the plaintext templates.
I could indeed use the {} strings, but yeah I like seeing the exact prompt being sent to the backend.
I also happen to have a lot of sessions currently that have specific formatting in them, from before the update that added Instruct templating, so this feature would also be nice for converting those older sessions.
You can see the exact prompt with everything filled in that's being sent to the model in the context modal (Persistent Context > Show Context), but I see your point.
Problem I see with the replacing formats is that either we'd have to check the prompt for all of the registered instruct formats, or explicitly specify which format we want to replace, since we currently have no way of elegantly figuring out what format a prompt used.
I'm also not sure this is something that should run every time you change your template, since I imagine this could get pretty expensive for long texts. But I don't know enough about js performance to say this with certainty.
It could also get finicky if the format doesn't exactly match what's defined in the templates.
Maybe it could get its own modal or collapsible where you can select "find" and "replace with" templates in two dropdowns?
Problem I see with the replacing formats is that either we'd have to check the prompt for all of the registered instruct formats, or explicitly specify which format we want to replace, since we currently have no way of elegantly figuring out what format a prompt used.
If necessary, I suggest we assume the last selected format is the correct one.
I'm also not sure this is something that should run every time you change your template, since I imagine this could get pretty expensive for long texts. But I don't know enough about js performance to say this with certainty.
I doubt the performance would be bad enough to matter, and imo performance should only be a consideration if the change could consistently impact React's render time.
It could also get finicky if the format doesn't exactly match what's defined in the templates.
I think the most robust way to handle this would be to parse the context with a function like this, then it would be simple enough to rewrite it using the new format.
Maybe it could get its own modal or collapsible where you can select "find" and "replace with" templates in two dropdowns?
+1 for a modal. But we could also add a checkbox to the instruct modal that says something like "Auto-replace old instruct format on change"
A find and replace feature would be interesting even on its own. Some general text editor programs have this which makes replacing several things at the same time quite nice and easy.