Class EnhancedResponse

java.lang.Object
com.tnsai.prompt.strategy.EnhancedResponse

public class EnhancedResponse extends Object
Parsed response from an enhanced prompt.

Extracts structured information from LLM responses based on the prompting strategies used.

Usage


 // Parse response with confidence scoring
 EnhancedResponse parsed = EnhancedResponse.parse(response.getContent());

 System.out.println("Answer: " + parsed.getMainContent());
 parsed.getConfidence().ifPresent(c ->
     System.out.println("Confidence: " + c + "%"));

 // Check structured thinking phases
 parsed.getPhase("UNDERSTAND").ifPresent(understand ->
     System.out.println("Understanding: " + understand));
 
  • Method Details

    • parse

      public static EnhancedResponse parse(String responseContent)
      Parses an LLM response to extract structured information.
    • getRawContent

      public String getRawContent()
      Gets the raw, unparsed response content.
    • getMainContent

      public String getMainContent()
      Gets the main content with metadata sections removed.
    • getConfidence

      public Optional<Float> getConfidence()
      Gets the confidence score if present.
      Returns:
      confidence as percentage (0-100)
    • isConfident

      public boolean isConfident(float threshold)
      Returns true if confidence is above the given threshold.
    • getAssumptions

      public List<String> getAssumptions()
      Gets the list of key assumptions.
    • getAlternatives

      public List<String> getAlternatives()
      Gets the list of alternative answers.
    • getVerificationQuestions

      public List<String> getVerificationQuestions()
      Gets the verification questions if using CoVe strategy.
    • getThinkingPhases

      public List<EnhancedResponse.ThinkingPhase> getThinkingPhases()
      Gets the thinking phases if using structured thinking.
    • getPhase

      public Optional<String> getPhase(String phaseName)
      Gets content of a specific thinking phase.
    • hasStructuredThinking

      public boolean hasStructuredThinking()
      Returns true if the response contains structured thinking phases.
    • hasVerification

      public boolean hasVerification()
      Returns true if the response has verification questions.
    • hasAlternatives

      public boolean hasAlternatives()
      Returns true if the response has alternatives.