Package com.tnsai.prompt
Class SimplePromptTemplate
java.lang.Object
com.tnsai.prompt.SimplePromptTemplate
- All Implemented Interfaces:
com.tnsai.prompt.PromptTemplate
Simple prompt template implementation using the SimpleTemplateEngine.
Usage
// Create from string
PromptTemplate template = SimplePromptTemplate.of(
"code-review",
"Review this {{language}} code for {{focus}}:\n\n{{code}}"
);
// Render with variables
String prompt = template.render(Map.of(
"language", "Java",
"focus", "security vulnerabilities",
"code", codeSnippet
));
// With metadata
PromptTemplate template = SimplePromptTemplate.builder("summarize")
.content("Summarize the following text in {{style}} style:\n\n{{text}}")
.metadata(PromptSpec.builder()
.version("1.0.0")
.requiredVariables("text")
.build())
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for SimplePromptTemplate. -
Method Summary
Modifier and TypeMethodDescriptionstatic SimplePromptTemplate.BuilderCreates a builder for templates.getName()com.tnsai.prompt.PromptSpecgetSpec()static SimplePromptTemplateCreates a simple template with name and content.toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.tnsai.prompt.PromptTemplate
hasAllVariables, render, validateVariables
-
Method Details
-
of
Creates a simple template with name and content.- Parameters:
name- the template namecontent- the template content- Returns:
- new template
-
builder
Creates a builder for templates.- Parameters:
name- the template name- Returns:
- new builder
-
getName
- Specified by:
getNamein interfacecom.tnsai.prompt.PromptTemplate
-
getContent
- Specified by:
getContentin interfacecom.tnsai.prompt.PromptTemplate
-
render
- Specified by:
renderin interfacecom.tnsai.prompt.PromptTemplate
-
getVariables
- Specified by:
getVariablesin interfacecom.tnsai.prompt.PromptTemplate
-
getSpec
public com.tnsai.prompt.PromptSpec getSpec()- Specified by:
getSpecin interfacecom.tnsai.prompt.PromptTemplate
-
toString
-