Class PromptTemplates

java.lang.Object
io.github.jbastgen.stemma.app.ai.PromptTemplates

public final class PromptTemplates extends Object
The texts Stemma puts around what it sends to an AI service. The defaults are built in; a template the user edited is a file <name>.txt in the prompts folder of the configuration, so it can be edited, copied and shared like any file. Deleting the file (or "Reset" in the settings) brings the default back.
  • Constructor Details

    • PromptTemplates

      public PromptTemplates(Path dir)
      Parameters:
      dir - the folder of the templates the user changed; the ready-made ones are in the code
  • Method Details

    • names

      public List<String> names()
      The names of all templates, in display order.
    • title

      public String title(String name)
      The name of the template shown to the user.
    • defaultText

      public String defaultText(String name)
      The ready-made text of the template.
    • get

      public String get(String name)
      The template to use: the user's if there is one, else the default.
    • customised

      public boolean customised(String name)
      Whether the user changed the template.
    • save

      public void save(String name, String text) throws IOException
      Stores the user's text for the template.
      Throws:
      IOException - for an unknown template or when the file cannot be written
    • reset

      public void reset(String name) throws IOException
      Removes the user's text, so the ready-made one applies again.
      Throws:
      IOException
    • withLanguage

      public static String withLanguage(String template, String language)
      Puts the language of the suggested message into a template: {language} is replaced by the name (empty = the language of the recent commit messages); a template that has no {language} (an older, edited one) gets a closing sentence.