lmg-anon / mikupad

LLM Frontend in a single html file
https://lmg-anon.github.io/mikupad/mikupad.html
Creative Commons Zero v1.0 Universal
233 stars 26 forks source link

Feature/instruct templates #56

Closed neCo2 closed 4 months ago

neCo2 commented 5 months ago

I've added functionality to select from a list of instruct formats. Then you can either click a button to insert the template directly into your prompt, or you can use placeholders, {sys} {/sys} {inst} and {/inst} in your prompt instead, which will be replaced with the selected instruct formats when being evaluated by the model. These placeholders can be used in the persistent context areas as well. Furthermore, you can add, delete, import and export templates. The UI's ugly as sin, so I'll be more than happy to implement any suggestions you can think of. firefox_2024-05-01_21-37-11 firefox_2024-05-01_19-49-38 firefox_2024-05-01_20-19-06

I've never worked with indexedDB before, so be sure to double check the code related to this. Judging by some situations I've seen early on, this has potential to lock up the entire page if the db version upgrade doesn't work as intended, until you either clear the storage, or downgrade mikupad.

neCo2 commented 5 months ago

Having used this for a week now, I'm not sure whether the selected template should be persistent or tied to session. Currently, it's persistent. What do you think?

lmg-anon commented 4 months ago

Sorry for my lateness, but this looks VERY solid!

Having used this for a week now, I'm not sure whether the selected template should be persistent or tied to session. Currently, it's persistent. What do you think?

In my opinion, it makes complete sense for the templates to be persistent. In fact, being tied to the session is an issue with how World Info works right now.

Anyway, I'm not very good with UIs either, but here are some of my thoughts for improvements:

neCo2 commented 4 months ago

Put the import/export stuff on a separate line and fixed the name and tooltip.

they are often associated with "Command Prompt" and "information," respectively

I know, but it's the best I could come up with apart from just an "S" and "I".

name change only reflects after you re-open the modal

Frankly, I can't figure out how to get the name to live-update without breaking stuff. I made it so that it makes an entry named "New Template" now instead of a completely blank entry. Maybe that helps a little.

In my opinion, it makes complete sense for the templates to be persistent. In fact, being tied to the session is an issue with how World Info works right now.

Just to be clear, I meant the selectedTemplate variable, not the actual templates object. Also what's the issue with world info being bound to sessions? I guess it's not ideal when you have an entry you want to use in multiple sessions, but could be mostly mitigated with import/export functions, which are probably way overdue anyways.

neCo2 commented 4 months ago

Added a chat mode similar to what #61 implemented, but working with the instruct templates. You can click the indicated Icon to switch between Completion and Chat mode. firefox_2024-05-19_14-30-05 Again unsure whether chat mode should be persistent or session-based.

lmg-anon commented 4 months ago

Frankly, I can't figure out how to get the name to live-update without breaking stuff. I made it so that it makes an entry named "New Template" now instead of a completely blank entry. Maybe that helps a little.

Yes, that is better, but I think you could implement live-updating like this. I just tested it here and it seems to work fine:

Just to be clear, I meant the selectedTemplate variable, not the actual templates object.

Oh yeah, selectedTemplate makes sense to be tied to the session, just like everything else in the "Parameters" group.

Also what's the issue with world info being bound to sessions? I guess it's not ideal when you have an entry you want to use in multiple sessions, but could be mostly mitigated with import/export functions, which are probably way overdue anyways.

Yes, it's just to be able to easily share with other sessions and avoid duplication of data. One could have a list of different World Infos, and easily switch between them. But I agree, import/export functions would mitigate this nicely.

Added a chat mode similar to what https://github.com/lmg-anon/mikupad/pull/61 implemented, but working with the instruct templates. You can click the indicated Icon to switch between Completion and Chat mode. Again unsure whether chat mode should be persistent or session-based.

This works pretty nicely, damn. I think this could also be tied to the session.

neCo2 commented 4 months ago

That works great! Added the live-updating just like you suggested, and tied selectedTemplate and chatMode to session. And now that the title's live-updating, I also changed back to a fully empty entry for adding a new template.

One could have a list of different World Infos, and easily switch between them

That's a great idea. It should be possible to copy a lot of the code of this PR to save and update WI to the indexedDB. Maybe I'll look into that.

neCo2 commented 4 months ago

Changed the indicated useMemos to useEffect and moved updateTemplateList inside the instruct modal. As I already said, I'd really appreciate it if you could handle the indexedDB stuff. Also I absolutely do not mind if you delay merging this PR until that is addressed.

lmg-anon commented 4 months ago

As I already said, I'd really appreciate it if you could handle the indexedDB stuff. Also I absolutely do not mind if you delay merging this PR until that is addressed.

No problem. I will try to handle it and commit to your branch before merging the PR.

neCo2 commented 4 months ago

Thanks a lot. Let me know if there's anything else you need me to do.

lmg-anon commented 4 months ago

Alright, I think this is it. If possible, I would like you to take a second look to see if you find anything that might have broken after these changes, but otherwise this should be fine to merge now.

neCo2 commented 4 months ago

Imports weren't working as templateStorage wasn't an argument for App() and the function still used sessionStorage.saveTemplates, but that's the only issue I found.

lmg-anon commented 4 months ago

Nice, thanks for another great contribution!

neCo2 commented 4 months ago

Thank you for polishing it up!