Record Class ExtractedKnowledge

java.lang.Object
java.lang.Record
com.tnsai.session.extraction.ExtractedKnowledge

public record ExtractedKnowledge(String id, ExtractionType type, String sessionId, String problem, String content, String summary, List<String> codeSnippets, List<String> relatedFiles, List<String> tags, double confidence, Instant extractedAt, Map<String,Object> metadata) extends Record
Represents knowledge extracted from a session.

Extracted knowledge can be of various types (solution, pattern, decision, etc.) and includes context about where and how it was learned.

Usage


 ExtractedKnowledge knowledge = ExtractedKnowledge.solution()
     .sessionId("session-123")
     .problem("JWT token expiration not handled")
     .content("Add refresh token mechanism with 401 interceptor")
     .codeSnippets(List.of("public class TokenRefreshInterceptor {...}"))
     .relatedFiles(List.of("AuthService.java", "TokenInterceptor.java"))
     .confidence(0.92)
     .build();
 
Author:
TnsAI Team
  • Constructor Details

    • ExtractedKnowledge

      public ExtractedKnowledge(String id, ExtractionType type, String sessionId, String problem, String content, String summary, List<String> codeSnippets, List<String> relatedFiles, List<String> tags, double confidence, Instant extractedAt, Map<String,Object> metadata)
      Creates an instance of a ExtractedKnowledge record class.
      Parameters:
      id - the value for the id record component
      type - the value for the type record component
      sessionId - the value for the sessionId record component
      problem - the value for the problem record component
      content - the value for the content record component
      summary - the value for the summary record component
      codeSnippets - the value for the codeSnippets record component
      relatedFiles - the value for the relatedFiles record component
      tags - the value for the tags record component
      confidence - the value for the confidence record component
      extractedAt - the value for the extractedAt record component
      metadata - the value for the metadata record component
  • Method Details

    • solution

      public static ExtractedKnowledge.Builder solution()
      Creates a builder for SOLUTION type knowledge.
    • pattern

      public static ExtractedKnowledge.Builder pattern()
      Creates a builder for PATTERN type knowledge.
    • decision

      public static ExtractedKnowledge.Builder decision()
      Creates a builder for DECISION type knowledge.
    • learning

      public static ExtractedKnowledge.Builder learning()
      Creates a builder for LEARNING type knowledge.
    • antipattern

      public static ExtractedKnowledge.Builder antipattern()
      Creates a builder for ANTIPATTERN type knowledge.
    • builder

      public static ExtractedKnowledge.Builder builder()
      Creates a general builder.
    • isHighConfidence

      public boolean isHighConfidence(double threshold)
      Checks if this knowledge has high confidence.
      Parameters:
      threshold - the confidence threshold (default 0.8)
      Returns:
      true if confidence is at or above threshold
    • isHighConfidence

      public boolean isHighConfidence()
      Checks if this knowledge has high confidence (threshold 0.8).
    • hasCodeSnippets

      public boolean hasCodeSnippets()
      Checks if this knowledge has code snippets.
    • hasRelatedFiles

      public boolean hasRelatedFiles()
      Checks if this knowledge has related files.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • type

      public ExtractionType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • sessionId

      public String sessionId()
      Returns the value of the sessionId record component.
      Returns:
      the value of the sessionId record component
    • problem

      public String problem()
      Returns the value of the problem record component.
      Returns:
      the value of the problem record component
    • content

      public String content()
      Returns the value of the content record component.
      Returns:
      the value of the content record component
    • summary

      public String summary()
      Returns the value of the summary record component.
      Returns:
      the value of the summary record component
    • codeSnippets

      public List<String> codeSnippets()
      Returns the value of the codeSnippets record component.
      Returns:
      the value of the codeSnippets record component
    • relatedFiles

      public List<String> relatedFiles()
      Returns the value of the relatedFiles record component.
      Returns:
      the value of the relatedFiles record component
    • tags

      public List<String> tags()
      Returns the value of the tags record component.
      Returns:
      the value of the tags record component
    • confidence

      public double confidence()
      Returns the value of the confidence record component.
      Returns:
      the value of the confidence record component
    • extractedAt

      public Instant extractedAt()
      Returns the value of the extractedAt record component.
      Returns:
      the value of the extractedAt record component
    • metadata

      public Map<String,Object> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component