Enum Class PromptStrategy

java.lang.Object
java.lang.Enum<PromptStrategy>
com.tnsai.prompt.strategy.PromptStrategy
All Implemented Interfaces:
Serializable, Comparable<PromptStrategy>, Constable

public enum PromptStrategy extends Enum<PromptStrategy>
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?");
 
  • Enum Constant Details

    • CHAIN_OF_THOUGHT

      public static final PromptStrategy 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

      public static final PromptStrategy 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

      public static final PromptStrategy 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

      public static final PromptStrategy STRUCTURED_THINKING
      Structured thinking protocol. Four-phase approach: UNDERSTAND → ANALYZE → STRATEGIZE → EXECUTE
    • MULTI_PERSPECTIVE

      public static final PromptStrategy MULTI_PERSPECTIVE
      Multi-perspective analysis. Examines problem from technical, business, UX, and risk perspectives.
    • CONSTRAINT_FIRST

      public static final PromptStrategy CONSTRAINT_FIRST
      Constraint-first prompting. Separates hard constraints from soft preferences.
    • ITERATIVE_REFINEMENT

      public static final PromptStrategy ITERATIVE_REFINEMENT
      Iterative refinement loop. Multi-pass generation: draft → critique → refine → review
    • CONTEXT_BOUNDARIES

      public static final PromptStrategy CONTEXT_BOUNDARIES
      Context with boundaries. Clear separation of context, focus, task, and constraints.
    • FEW_SHOT_EXAMPLES

      public static final PromptStrategy FEW_SHOT_EXAMPLES
      Few-shot with examples. Uses examples (positive and negative) to guide response format.
    • META_PROMPTING

      public static final PromptStrategy META_PROMPTING
      Meta-prompting. AI generates optimal prompt for task, then executes it.
    • SIX_PART_ANATOMY

      public static final PromptStrategy SIX_PART_ANATOMY
      6-Part Prompt Anatomy. Comprehensive structure: Role, Objective, User Request, Process, Output Format, Stop Condition.
    • ATOM_OF_THOUGHT

      public static final PromptStrategy 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

      public static PromptStrategy[] 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

      public static PromptStrategy valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getSystemInstruction

      public String getSystemInstruction()
      Gets the system instruction to inject for this strategy.
    • getDescription

      public String 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.