Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /slash command system to chat mode, with memory related and /worldinfo commands #58

Draft
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

one-lithe-rune
Copy link
Contributor

@one-lithe-rune one-lithe-rune commented Feb 1, 2024

Motivation

I got to thinking that the model should be able to add and recall things outside its context window for the character it is playing by just saying saying some sort of 'magic words' which lite would parse. After some fiddling about I realised that since this is chat mode, the 'magic words' would probably make most sense as /slash commands.

I thought about reusing world info as the memory store, but that seemed dubious. Instead this implements the memory as a very simplistic dictionary of saved responses, and has a separate /slash command to lookup (but not change) world info

Changes

(fdd7da4)

  • Add a basic slash command system.
  • Add a /help command for chat mode.

(b321298)

  • Refactor worldInfo retrieval into its own function
  • Add a /memorize command for chat mode
  • Add a /recall command for chat mode
  • Add a /worldinfo command for chat mode
  • Fixes to when and how / commands are parsed for both input and generation.

To Do

  • localsetting for enabling/disabling chat commands + UI (separate setting for user and bot) (44ba115)
  • localsetting for name of under which / commands replies are shown (UI? No UI) (44ba115)
  • localsettings for / command response templates (probably no UI atm) (7343a56)

Possible Problems/Concerns

  • /slash commands might not have been the best idea. Although they're probably something any given model probably has the general idea of, because of that they're also something models like to hallucinate. This is why I truncate anything after a /slash command.
  • Memory system allows memorization of the last response from a specified character, rather than anything arbitrary.
  • I've been mostly coding on this, rather trying to get any model to actually use the commands, so it may turn out that the memory bits are not super useful.

* Adds a /help slash command to chat mode usable by both user and bot
* Refactor worldInfo retrieval into its own function
* Add a /memorize command for chat mode
* Add a /recall command for chat mode
* Add a /worldinfo command for chat mode
* Fixes to when and how / commands are parsed for both input and generation.
@esolithe
Copy link

esolithe commented Feb 1, 2024

Like the idea of this - Just a thought from my side though from some quick tests:

  • The basic functionality seems to work from my tests:
    • image
    • And gets some basic AI comments to sometimes!
  • Some commands, like help, might be better if they prevent actual AI generation I think. As it doesn't make much sense in my opinion to get AI comments on some commands.
    • image
    • Maybe can be part of the UI as a toggle per command?
  • I suspect the recall / memorize would be useful in WI variants to, one of the more common requests I hear often comes down to "Can I save the last response as world info" or highlight a bit and put it into WI. Could be a nice thing to support.
  • This is a bit of a longer shot, but I'm also pretty interested in seeing if we could do some sort of hover menu - i.e. starting with a slash opens a menu with command suggestions - though this is way overkill I think so probably one to ignore.

If you think these might be interesting I can probably give them a tinker, I'm pretty intrigued by the ideas to generate world info / potentially even run things like "Summarise the context before into memory" similar to the auto generate memory but with a single line command / clean up.

All these ideas of mine are more in future with how extensible this system could be, not right now - Just opens up quite a few nice quick options for commands from the keyboard with I'm all in favour 👍 !

@one-lithe-rune
Copy link
Contributor Author

one-lithe-rune commented Feb 1, 2024

Some commands, like help, might be better if they prevent actual AI generation I think. As it doesn't make much sense in my opinion to get AI comments on some commands.

Yes, I thought of having the turn stay with whichever of You or the AI entered the command. I think that does make sense. But changing the turn order -- along with getting it to work for Instruct and maybe Adventure -- looked non-obvious enough at an initial glance that I decided to KISS and concentrate on basics.

I suspect the recall / memorize would be useful in WI variants to, one of the more common requests I hear often comes down to "Can I save the last response as world info" or highlight a bit and put it into WI. Could be a nice thing to support.

My reasoning on having the memories separate from the world info, was that I didn't think people would want the AI putting random stuff in it willy nilly, and the genesis of the idea was for the AI to be able to do things through the commands. We would probably need to make that an User only command.

The one world info thing I did wonder about was whether there needs to be a way to allow you to have world info, so you can get at it with the /worldinfo command, but not have it be inserted in the usual way. But I'm not really familiar with how people use world info.

The couple of extra commands that seemed obvious to me to do at some point would be one to trigger an image generation (so the AI could do it as well as you), and another to grab something from a URL. The summarisation one also makes sense, you would probably need summarisation for the URL one anyway.

I think those are future though. Another thought I had was seeing whether its possible to load up a separate .js file with additional commands, as a kind of command plugin/make your own command system. Not sure whether that is direction we want to go though.

For the current PR, I'm considering whether I should split the enable/disable into separate 'enable for AI' and 'enable for User' options, and whether the other TODOs I have for the local setting stuff should actually be saved with the Memory in the save file rather than as general settings.

one-lithe-rune and others added 3 commits February 2, 2024 14:54
* Add a setting + UI for enabling and disabling /commands for the AI.
* Add a setting + UI for enabling and disabling /commands for the User.
* Default these new settings to false/disabled.
* Add a setting specifying the name that /command results are returned
from. Default is 'System' (No UI)
* Rename /command functions from snake_case to camelCase.
* Define the responses for memory /commands in `current_char_memory_templates`
instead of hardcoding them in the code.
* Save `current_char_memory_templates` settings alongside the character memories
in the save file.
* Fix /memorize and /recall behaviour, when no arguments given.
* Remove some inappropriate newlines from /command responses.
@one-lithe-rune one-lithe-rune marked this pull request as ready for review February 2, 2024 20:32
@one-lithe-rune
Copy link
Contributor Author

UI Changes, adding to the Basic settings for chat:

lite-pr58-settings-additions

List of /commands:

lite-pr58-slash-command-list

@LostRuins LostRuins changed the base branch from main to dev February 3, 2024 09:41
@one-lithe-rune one-lithe-rune marked this pull request as draft February 3, 2024 14:03
* Rename /memorize to /note and update function
and variable names to match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants