Record Class RAGContext

java.lang.Object
java.lang.Record
com.tnsai.intelligence.rag.RAGContext
Record Components:
maxResults - maximum number of documents to retrieve (must be positive)
minScore - minimum relevance score threshold; documents below this are discarded
metadataFilters - exact key-value constraints on retrieved-document metadata (empty = no filtering)

public record RAGContext(int maxResults, double minScore, Map<String,String> metadataFilters) extends Record
Configuration context for a RAG retrieval request.

Provides the maximum number of results, minimum relevance score threshold, and optional metadata filters that strategies use to narrow the result set. A document matches when its metadata contains an exactly equal value for every filter entry. Missing keys do not match, and filtering is applied before maxResults.

Since:
0.2.4
  • Field Details

    • DEFAULT_MAX_RESULTS

      public static final int DEFAULT_MAX_RESULTS
      Default maximum results when not specified.
      See Also:
    • DEFAULT_MIN_SCORE

      public static final double DEFAULT_MIN_SCORE
      Default minimum score (no threshold).
      See Also:
  • Constructor Details

    • RAGContext

      public RAGContext(int maxResults, double minScore, Map<String,String> metadataFilters)
      Canonical constructor with validation.
    • RAGContext

      public RAGContext()
      Creates a context with defaults (10 results, no score threshold, no filters).
    • RAGContext

      public RAGContext(int maxResults)
      Creates a context with a specific max results count.
      Parameters:
      maxResults - maximum number of documents to retrieve
  • Method Details

    • withMaxResults

      public RAGContext withMaxResults(int maxResults)
      Returns a new context with an updated max results value.
      Parameters:
      maxResults - the new maximum results count
      Returns:
      a new RAGContext with the updated value
    • withMinScore

      public RAGContext withMinScore(double minScore)
      Returns a new context with an updated minimum score threshold.
      Parameters:
      minScore - the new minimum score
      Returns:
      a new RAGContext with the updated value
    • withMetadataFilters

      public RAGContext withMetadataFilters(Map<String,String> filters)
      Returns a new context with the given metadata filters.
      Parameters:
      filters - the metadata filters
      Returns:
      a new RAGContext with the updated filters
    • 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.
    • maxResults

      public int maxResults()
      Returns the value of the maxResults record component.
      Returns:
      the value of the maxResults record component
    • minScore

      public double minScore()
      Returns the value of the minScore record component.
      Returns:
      the value of the minScore record component
    • metadataFilters

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