Package com.tnsai.prompt.strategy
Enum Class PromptStrategy
- All Implemented Interfaces:
Serializable,Comparable<PromptStrategy>,Constable
Predefined prompting strategies for enhanced LLM responses.
These strategies are based on techniques used by OpenAI, Anthropic, and Google AI engineers to improve response quality.
Usage
// Single strategy
PromptEnhancer enhancer = PromptEnhancer.withStrategy(PromptStrategy.CHAIN_OF_THOUGHT);
// Multiple strategies
PromptEnhancer enhancer = PromptEnhancer.builder()
.strategy(PromptStrategy.CHAIN_OF_THOUGHT)
.strategy(PromptStrategy.CONFIDENCE_WEIGHTED)
.build();
EnhancedPrompt enhanced = enhancer.enhance("What is the capital of France?");
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAtom of Thought (AoT) reasoning.Chain-of-Thought (CoT) prompting.Chain-of-Verification (CoVe) prompting.Confidence-weighted responses.Constraint-first prompting.Context with boundaries.Few-shot with examples.Iterative refinement loop.Meta-prompting.Multi-perspective analysis.6-Part Prompt Anatomy.Structured thinking protocol. -
Method Summary
Modifier and TypeMethodDescriptionGets a short description of this strategy.Gets the system instruction to inject for this strategy.booleanReturns true if this strategy benefits from multiple LLM calls.booleanReturns true if this strategy requires post-processing of the response.static PromptStrategyReturns the enum constant of this class with the specified name.static PromptStrategy[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
CHAIN_OF_THOUGHT
Chain-of-Thought (CoT) prompting. Encourages step-by-step reasoning before giving final answer.Best for: Math problems, logical reasoning, multi-step analysis.
-
CHAIN_OF_VERIFICATION
Chain-of-Verification (CoVe) prompting. Self-verification with generated questions to improve accuracy.Process: Initial answer → Generate verification questions → Answer them → Refine
Accuracy improvement: 60% → 92% on complex queries
-
CONFIDENCE_WEIGHTED
Confidence-weighted responses. Includes confidence scores and key assumptions.Output includes: confidence score (0-100%), key assumptions, alternatives when confidence invalid input: '<' threshold
-
STRUCTURED_THINKING
Structured thinking protocol. Four-phase approach: UNDERSTAND → ANALYZE → STRATEGIZE → EXECUTE -
MULTI_PERSPECTIVE
Multi-perspective analysis. Examines problem from technical, business, UX, and risk perspectives. -
CONSTRAINT_FIRST
Constraint-first prompting. Separates hard constraints from soft preferences. -
ITERATIVE_REFINEMENT
Iterative refinement loop. Multi-pass generation: draft → critique → refine → review -
CONTEXT_BOUNDARIES
Context with boundaries. Clear separation of context, focus, task, and constraints. -
FEW_SHOT_EXAMPLES
Few-shot with examples. Uses examples (positive and negative) to guide response format. -
META_PROMPTING
Meta-prompting. AI generates optimal prompt for task, then executes it. -
SIX_PART_ANATOMY
6-Part Prompt Anatomy. Comprehensive structure: Role, Objective, User Request, Process, Output Format, Stop Condition. -
ATOM_OF_THOUGHT
Atom of Thought (AoT) reasoning. Decomposes complex problems into independent atoms solved in parallel.Unlike Chain-of-Thought which processes linearly (where errors propagate), AoT processes atoms in parallel, isolating errors.
Benefits: +30-40% accuracy on complex reasoning, error isolation
Trade-off: +20-30% token usage
Best for: 70B+ parameter models, complex multi-step problems
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getSystemInstruction
Gets the system instruction to inject for this strategy. -
getDescription
Gets a short description of this strategy. -
requiresPostProcessing
public boolean requiresPostProcessing()Returns true if this strategy requires post-processing of the response. -
isMultiPass
public boolean isMultiPass()Returns true if this strategy benefits from multiple LLM calls.
-