justyns / silverbullet-ai

Plug for SilverBullet to integrate LLM functionality
https://ai.silverbullet.md/
GNU Affero General Public License v3.0
26 stars 1 forks source link

Suggest name command #28

Closed zefhemel closed 2 months ago

zefhemel commented 2 months ago

I often use Quick Note to quickly jot something down. Afterwards it's hard to find and I cannot always be bothered to come up with a proper page name. I think AI can help here. ChatGPT always comes up with reasonable names for chats and I think this plug could do the same.

What I'm suggesting is a "AI: Suggest Page Name" (or similar) command that based on the page content suggests perhaps 3 possible names (in a filtered list for instance) and if the user selects one, renames the page.

I can imagine that in practice you'd want to guide AI a bit in your naming schemes so perhaps a type of preprompt text setting may be useful as well.

zefhemel commented 2 months ago

The more I think about it, the more I believe a way to instruct it will be vital. For instance I may want to say something along the lines of "if this page contains a #blog tag, make sure the page title is prefixed with Blog/"

justyns commented 2 months ago

@zefhemel Thanks for the suggestion! I have a few helper spacescript commands like 'Move to Receipts' that this could potentially replace. It's available in the main branch now if you want to give it a try. By default, it'll use this prompt:

You are an AI note-naming assistant. Your task is to suggest three to five possible names for the provided note content. Please adhere to the following guidelines:
- Provide each name on a new line.
- Avoid most special characters or symbols. Spaces are acceptable. Forward slashes are allowed as folder seperators. Hyphens are allowed.
- Ensure the names are concise and relevant to the content.
- Avoid suggesting the same name as the current note.
- Include as much detail as possible within 3 to 10 words.
- Do not change the folder or prefix of the note name unless explicitly requested by the user.
- Include the current folder name (with trailing /) in the suggestion.
- Retain ALL date and time information from the original note title.

Always follow the below rules, if any, given by the user:
${aiSettings.promptInstructions.pageRenameRules}`,

You can give it additional instructions in SETTINGS like:

ai:
  promptInstructions:
    pageRenameRules: |
      If there is a date or time at the beginning, ensure a hyphen seperates the timestamp from the actual note title.  For example, try to name quick notes like this: "YYYY-MM-DD HH:MM:SS - A short title about the note"
      If tags include #receipt or otherwise looks like a receipt, move it to "Receipts/YYYY/MM-MMMM/" using the date from the note metadata.

I might come back and update that first prompt since it seems pretty verbose, but so far it seems to be working pretty well for me.

zefhemel commented 2 months ago

Very cool, looking forward to use this!

zefhemel commented 2 months ago

A few things:

  1. Since this is a bit laggy, some indication (flashNotification maybe?) that suggest something is happening would be nice. I sometimes am not sure if I ran the command properly
  2. Why is the suggestion shown both as a primary select, as well as a hint? CleanShot 2024-07-04 at 18 44 36@2x
  3. Maybe use "New page name" instead of "Select a page name" and put something in the helpText so it doesn't look so empty in the UI.

Since I will mostly use this for quick notes, I'm using this custom prompt to undo some of your default prompting. Not sure if this is desirable, something to think about:

  promptInstructions:
    pageRenameRules: |
      If the page name starts with Inbox/ remove that part from the name and remove any date and timestamp from it too. Don't have names start with any non ASCII character either. 
justyns commented 2 months ago

Since this is a bit laggy, some indication (flashNotification maybe?) that suggest something is happening would be nice. I sometimes am not sure if I ran the command properly

I'll add that. I sort of have this problem with anything that doesn't stream results directly to the page, but don't have a strong opinion on how to make it better. Is there a way to open a filterbox immediately with the text "loading.." and then replace it with real options once they're available?

2/3: I originally had it show just the new page name, but the hint was the full path to the file. I changed that to let the llm change the folder name too. It can be removed

Since I will mostly use this for quick notes, I'm using this custom prompt to undo some of your default prompting. Not sure if this is desirable, something to think about:

Hmm, I thought I chose sane defaults but some of what you do is the opposite of what I want, like removing timestamps. Maybe I'll trim it down to be as basic as possible, and leave it up to the user for any specific rules like keeping the folder prefix/etc

justyns commented 2 months ago

Alright this is in main now, how's this look?

page-rename-with-loading

Instead of a flashnotification, it opens a temporary filterbox that just says loading, and then replaces it with the actual filterbox once it has the results.

I haven't checked yet if it's possible, but it would be cool if we could have the filterbox have some sort of api or callback that acts like an auto complete. So it would have the current behavior it has now, but if you started typing in the filterbox input - it could generate a new set of titles based on what you typed.

zefhemel commented 2 months ago

Just upgraded. Nice! Loving this.