Package com.tnsai.rag
Record Class KnowledgeSelection
java.lang.Object
java.lang.Record
com.tnsai.rag.KnowledgeSelection
- Record Components:
entries- the sources in scope, in declaration ordersearch- the merged search configuration over the SEARCH sources, or empty when the scope has none; itssourcesare the SEARCH names
public record KnowledgeSelection(List<KnowledgeEntry> entries, Optional<RetrievalConfig> search)
extends Record
The knowledge one scope sees: an action's named sources, or a chat turn's
whole agent knowledge.
Every source behaves by its own Knowledge.Use: DIRECT sources
enter whole, SEARCH sources run through one engine configured by
search(), and a SEQUENTIAL source contributes its next unit. The
blocks join in entries() order, which is declaration order.
- Since:
- 0.18.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intShare of the model input window DIRECT sources may fill by default.static final KnowledgeSelectionA scope that sees no knowledge. -
Constructor Summary
ConstructorsConstructorDescriptionKnowledgeSelection(List<KnowledgeEntry> entries, Optional<RetrievalConfig> search) Creates an instance of aKnowledgeSelectionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionentries()Returns the value of theentriesrecord component.entries(Knowledge.Use use) final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanisEmpty()booleanvoidrequireDirectBudget(Map<String, Integer> measuredTokens, int maxInputTokens) Checks the DIRECT sources' measured size against their budgets.search()Returns the value of thesearchrecord component.sources()final StringtoString()Returns a string representation of this record class.
-
Field Details
-
EMPTY
A scope that sees no knowledge. -
DEFAULT_DIRECT_SHARE_PERCENT
public static final int DEFAULT_DIRECT_SHARE_PERCENTShare of the model input window DIRECT sources may fill by default.- See Also:
-
-
Constructor Details
-
Method Details
-
isEmpty
public boolean isEmpty()- Returns:
truewhen the scope sees no knowledge
-
sources
- Returns:
- the source configurations in scope, in declaration order
-
entries
- Parameters:
use- a usage mode- Returns:
- the entries with that mode, in declaration order
-
needsInputWindow
public boolean needsInputWindow()- Returns:
truewhen a DIRECT source relies on the default budget, which needs the model input window
-
requireDirectBudget
Checks the DIRECT sources' measured size against their budgets.A source with
maxTokensmust fit that on its own. The sources without it share 25% of the model input window, counted over their sum. Nothing falls back to search: a source that does not fit is a configuration error. Every failure names the source, its measured tokens and the budget; a shared-budget failure lists each source's tokens and their sum.- Parameters:
measuredTokens- tokens each DIRECT source renders to, by namemaxInputTokens- the model input window, or a non-positive value when it is unknown- Throws:
IllegalStateException- when a source is over its budget, or the default budget is needed and the window is unknown
-
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. -
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. -
equals
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. All components in this record class are compared withObjects::equals(Object,Object). -
entries
Returns the value of theentriesrecord component.- Returns:
- the value of the
entriesrecord component
-
search
Returns the value of thesearchrecord component.- Returns:
- the value of the
searchrecord component
-