Package com.tnsai.rag

Record Class KnowledgeSourceConfig

java.lang.Object
java.lang.Record
com.tnsai.rag.KnowledgeSourceConfig

public record KnowledgeSourceConfig(String name, Knowledge.Type type, DocumentFormat format, String path, String connection, String query, boolean enabled, List<String> include, List<String> exclude, KnowledgeUnit unit, ChunkContext chunkContext, String chunkContextModel, String select) extends Record
Immutable runtime configuration for one RAG knowledge source.

Both Knowledge declarations and AgentBuilder sources are normalized to this model before reaching source loaders.

It carries ingestion configuration only — what to load and from where. select keeps the part of each loaded document at and below a structural path; blank keeps it whole. How the loaded documents are then used is KnowledgeEntry's to say, and how they are searched is normalized to RetrievalConfig rather than to this record.

Since:
0.13.0
  • Constructor Details

  • Method Details

    • from

      public static KnowledgeSourceConfig from(Knowledge knowledge)
      Converts a Knowledge declaration's source members to the canonical runtime model.

      How the source is used (use, maxTokens, search) is not part of this record; KnowledgeEntry carries it.

      Parameters:
      knowledge - the declaration
      Returns:
      the source configuration
      Since:
      0.13.0
    • builder

      public static KnowledgeSourceConfig.Builder builder(String name, Knowledge.Type type)
    • withPath

      public KnowledgeSourceConfig withPath(String resolvedPath)
      Returns a copy of this declaration with only the location replaced.

      Everything a @Knowledge declaration can say — name, type, format, selectors, unit, chunk context — stays declarative and is carried over unchanged. Only path is supplied here, for the one thing an annotation cannot express: a location that does not exist until run time, such as a per-run transcript directory.

      The replacement must be non-blank. A blank override would silently reproduce the "declared but unlocated" state this method exists to leave behind.

      Parameters:
      resolvedPath - the location, known now, that the declaration could not name at compile time
      Returns:
      a new configuration equal to this one except for path
      Since:
      0.16.0
    • withSelection

      public KnowledgeSourceConfig withSelection(Knowledge.Type type, String path, KnowledgeUnit unit)
      Copies this configuration with optional type, path and unit selections. Null keeps the current field; an explicit AUTO unit selects AUTO. A non-null path must be non-blank. Every other field is preserved and the canonical constructor validates the resulting combination.
      Parameters:
      type - selected type, or null to keep the current type
      path - selected path, or null to keep the current path
      unit - selected unit, or null to keep the current unit
      Returns:
      an immutable configuration with the selected fields
    • file

      public static KnowledgeSourceConfig file(String name, String path)
    • memory

      public static KnowledgeSourceConfig memory(String name)
      A MEMORY source: chat knowledge the application supplies at runtime through a ChatKnowledgeBinding. It names the binding's source and nothing else; initialization loads nothing for it.
      Parameters:
      name - the source name the runtime binding carries
      Returns:
      an enabled MEMORY source
      Since:
      0.18.0
    • 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.
    • name

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

      public Knowledge.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • format

      public DocumentFormat format()
      Returns the value of the format record component.
      Returns:
      the value of the format record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • connection

      public String connection()
      Returns the value of the connection record component.
      Returns:
      the value of the connection record component
    • query

      public String query()
      Returns the value of the query record component.
      Returns:
      the value of the query record component
    • enabled

      public boolean enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component
    • include

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

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

      public KnowledgeUnit unit()
      Returns the value of the unit record component.
      Returns:
      the value of the unit record component
    • chunkContext

      public ChunkContext chunkContext()
      Returns the value of the chunkContext record component.
      Returns:
      the value of the chunkContext record component
    • chunkContextModel

      public String chunkContextModel()
      Returns the value of the chunkContextModel record component.
      Returns:
      the value of the chunkContextModel record component
    • select

      public String select()
      Returns the value of the select record component.
      Returns:
      the value of the select record component