justyns / silverbullet-ai

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

Custom instructions for chat #7

Closed zefhemel closed 8 months ago

zefhemel commented 8 months ago

ChatGPT has this feature "custom instructions" which I think just invisibly injects the text more or less verbatim in the original prompt. It's very useful to have a place to add these instructions once, and not have to re-enter them for every chat:

CleanShot 2024-02-25 at 15 29 18@2x

Seems like something easy to add? Not sure how to best configure this, though. Perhaps a dedicated page? A setting pointing to a page with these instructions, some other way?

justyns commented 8 months ago

You can sort of do this with a template, e.g. this is my "New AI Chat" page template:

---
description: "Create a chat session with your LLM"
tags: template
hooks.newPage:
  suggestedName: "Inbox/{{today}} {{time}} - AI Chat"
  confirmName: false
  command: "New AI Chat"
  key: "Alt-Shift-c"
frontmatter:
  dateCreated: "{{today}}"
---

**system**: You are an AI note assistant in a markdown-based note tool.  You are having an interactive chat with the user.  Keep your responses short and concise.

**assistant**: Hello, how can I help you?

**user**: |^|

The first **system**: could be changed to include this information. It's not as convenient as having it always available though, adding it to the settings page probably would be fine. Something like aisettings.userInformation and aisettings.userInstructions and just add those automatically to the first system message by default

zefhemel commented 8 months ago

Right yeah I suppose adding it to a page template is another way.

justyns commented 8 months ago

Thinking about this more, what do you think about this in SETTINGS?

indexPage: index

ai:
  defaultTextModel: gpt-4-0125-preview
  # openAIBaseUrl: http://localhost:11434/v1
  # defaultTextModel: phi
  # requireAuth: false
  chat:
    userInformation: >
      I'm a person.
    userInstructions: >
      Please give short and concise responses.  When providing code, do so in python unless requested otherwise.

And then those two fields would only get used by the "Chat" command. Any other prompts would still be able to set their own system prompt so they don't have to worry about random things being injected into the prompt. I like the idea of a default system prompt for everything but I also think it could cause confusion.

zefhemel commented 8 months ago

Makes sense to me. Putting it in SETTINGS is fine I think.

justyns commented 8 months ago

If you want to give it a try, I just pushed it to main

zefhemel commented 8 months ago

Seems to work!

Where do I live?

**assistant**: You live in Poland.