Package com.tnsai.prompt
Class PromptTemplateLoader
java.lang.Object
com.tnsai.prompt.PromptTemplateLoader
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 Summary
Modifier and TypeMethodDescriptionstatic voidClears the template cache.loadTemplates(Class<?> roleClass) Loads templates for a role class annotated withPromptTemplates.static StringResolves a template key to a formatted string with the given values.
-
Method Details
-
loadTemplates
Loads templates for a role class annotated withPromptTemplates.- 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 mapkey- the template key (from@State(template = "key"))name- the state field namevalue- the current runtime valuedescription- the state description- Returns:
- resolved string, or null if key not found
-
clearCache
public static void clearCache()Clears the template cache.
-