Package com.tnsai.rag
Record Class KnowledgeUsage
java.lang.Object
java.lang.Record
com.tnsai.rag.KnowledgeUsage
- Record Components:
source- the knowledge namemode- how the source was useddocumentCount- documents (or units) that reached the modeltokens- estimated tokens those documents rendered to
public record KnowledgeUsage(String source, Knowledge.Use mode, int documentCount, int tokens)
extends Record
What one knowledge source gave a chat turn or an action call.
A call reports one row per enabled source in its scope, in declaration order, including a source that gave nothing (count and tokens 0):
- DIRECT: the documents given whole and their estimated tokens
- SEARCH: the retrieved documents that fit the context window and reached the model, attributed to the source each came from. With one SEARCH source in scope, every fitted document is that source's; a GRAPH source is always alone, so its row counts the graph evidence rendered. Tokens are the sum of each document's rendered estimate.
- SEQUENTIAL: 1 when the source gave its next unit, 0 when it is exhausted, with that unit's estimated tokens
Actions publish the rows under
RetrievalSpi.RETRIEVED_KNOWLEDGE_USAGE_KEY; an agent built with
AgentBuilder.knowledgeUsageListener also receives them for each
chat turn and action call.
- Since:
- 0.18.0
-
Constructor Summary
ConstructorsConstructorDescriptionKnowledgeUsage(String source, Knowledge.Use mode, int documentCount, int tokens) Creates an instance of aKnowledgeUsagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of thedocumentCountrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.mode()Returns the value of themoderecord component.source()Returns the value of thesourcerecord component.inttokens()Returns the value of thetokensrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
KnowledgeUsage
Creates an instance of aKnowledgeUsagerecord class.- Parameters:
source- the value for thesourcerecord componentmode- the value for themoderecord componentdocumentCount- the value for thedocumentCountrecord componenttokens- the value for thetokensrecord component
-
-
Method Details
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
mode
Returns the value of themoderecord component.- Returns:
- the value of the
moderecord component
-
documentCount
public int documentCount()Returns the value of thedocumentCountrecord component.- Returns:
- the value of the
documentCountrecord component
-
tokens
public int tokens()Returns the value of thetokensrecord component.- Returns:
- the value of the
tokensrecord component
-