Class PromptTemplateLoader

java.lang.Object
com.tnsai.prompt.PromptTemplateLoader

public final class PromptTemplateLoader extends Object
Loads and caches prompt template files referenced by PromptTemplates.

Templates are loaded from the classpath as Java properties files. Supports ${value}, ${name}, and ${description} placeholders.

Author:
TnsAI Team
  • Method Details

    • loadTemplates

      public static Map<String,String> loadTemplates(Class<?> roleClass)
      Loads templates for a role class annotated with PromptTemplates.
      Parameters:
      roleClass - the role class
      Returns:
      template map (key → pattern), empty if no annotation or file not found
    • resolve

      public static String resolve(Map<String,String> templates, String key, String name, String value, String description)
      Resolves a template key to a formatted string with the given values.
      Parameters:
      templates - the loaded template map
      key - the template key (from @State(template = "key"))
      name - the state field name
      value - the current runtime value
      description - the state description
      Returns:
      resolved string, or null if key not found
    • clearCache

      public static void clearCache()
      Clears the template cache.