Package com.tnsai.prompt.strategy
Class EnhancedResponse
java.lang.Object
com.tnsai.prompt.strategy.EnhancedResponse
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));
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord for thinking phases (UNDERSTAND, ANALYZE, STRATEGIZE, EXECUTE). -
Method Summary
Modifier and TypeMethodDescriptionGets the list of alternative answers.Gets the list of key assumptions.Gets the confidence score if present.Gets the main content with metadata sections removed.Gets content of a specific thinking phase.Gets the raw, unparsed response content.Gets the thinking phases if using structured thinking.Gets the verification questions if using CoVe strategy.booleanReturns true if the response has alternatives.booleanReturns true if the response contains structured thinking phases.booleanReturns true if the response has verification questions.booleanisConfident(float threshold) Returns true if confidence is above the given threshold.static EnhancedResponseParses an LLM response to extract structured information.
-
Method Details
-
parse
Parses an LLM response to extract structured information. -
getRawContent
Gets the raw, unparsed response content. -
getMainContent
Gets the main content with metadata sections removed. -
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
Gets the list of key assumptions. -
getAlternatives
Gets the list of alternative answers. -
getVerificationQuestions
Gets the verification questions if using CoVe strategy. -
getThinkingPhases
Gets the thinking phases if using structured thinking. -
getPhase
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.
-