Class PromptTemplate
java.lang.Object
com.codename1.ai.PromptTemplate
Trivial {placeholder} substitution. Designed for the common
"build a prompt from a handful of fields" pattern without pulling
in a templating library. For anything more sophisticated (loops,
conditionals) just compose strings directly.
String prompt = PromptTemplate.of(
"You are an expert {role}. Reply in {style}."
).put("role", "tax accountant").put("style", "bullet points").build();
-
Method Summary
Modifier and TypeMethodDescriptionasSystem()Convenience: render and wrap as aChatMessagewith SYSTEM role.asUser()Convenience: render and wrap as aChatMessagewith USER role.build()Renders the final string.static PromptTemplate
-
Method Details
-
of
-
put
-
putAll
-
build
Renders the final string. Unknown placeholders are left intact ({like_this}) so they're easy to spot in test output -- silently dropping them tends to hide bugs. -
asUser
Convenience: render and wrap as aChatMessagewith USER role. -
asSystem
Convenience: render and wrap as aChatMessagewith SYSTEM role.
-