Package com.tnsai.rag
Class ChatKnowledgeBindingValidator
java.lang.Object
com.tnsai.rag.ChatKnowledgeBindingValidator
The one rule a chat knowledge binding must meet before it grounds a
conversation, whoever installs it: an agent, its builder or an integration.
A binding is valid for an owner when
- a declaration backs it: it is not
undeclared; - it belongs to that exact owner: its owner id equals the owner's id when the caller knows one, and its exact owner object, when it was created with one, is the owner itself;
- every source it searches is an enabled SEARCH entry of the owner's
chat knowledge, as
KnowledgeDeclarations.chatScope(List)reads it, so a GRAPH entry never backs a binding; - it searches the
MEMORYentry alone or only the other SEARCH entries, since a chat turn searches the two kinds each on its own; and - its topK equals the topK the SEARCH entries of its kind declare,
merged field by field over
KnowledgeDeclarations.chatSearchDefaults()as the agent wires them.
AgentBuilder gives is layered into the same entries
first, so it is checked the same way.- Since:
- 0.18.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleansearchesMemory(ChatKnowledgeBinding binding, List<KnowledgeEntry> knowledge) Whether a binding searches the MEMORY entry of the given knowledge rather than its other SEARCH entries: whether any of its sources names an enabled MEMORY entry of the chat scope.static voidvalidate(ChatKnowledgeBinding binding, Object owner, String ownerId, List<KnowledgeEntry> knowledge, String where) Checks a binding against the owner's declared knowledge.
-
Method Details
-
validate
public static void validate(ChatKnowledgeBinding binding, Object owner, String ownerId, List<KnowledgeEntry> knowledge, String where) Checks a binding against the owner's declared knowledge.- Parameters:
binding- the binding to installowner- the exact conversation ownerownerId- the owner's id, ornullwhen the caller has none and the binding must name the owner objectknowledge- the owner's knowledge entries; only the SEARCH ones in its chat scope countwhere- the declaration site, used in messages- Throws:
IllegalArgumentException- when the binding breaks the rule or isundeclared
-
searchesMemory
Whether a binding searches the MEMORY entry of the given knowledge rather than its other SEARCH entries: whether any of its sources names an enabled MEMORY entry of the chat scope. A binding thatvalidate(com.tnsai.rag.ChatKnowledgeBinding, java.lang.Object, java.lang.String, java.util.List<com.tnsai.rag.KnowledgeEntry>, java.lang.String)accepts searches one kind only.- Parameters:
binding- a chat bindingknowledge- the owner's knowledge entries- Returns:
- whether the binding searches the MEMORY entry
- Since:
- 0.18.6
-