Package com.tnsai.rag

Class ChatKnowledgeBindingValidator

java.lang.Object
com.tnsai.rag.ChatKnowledgeBindingValidator

public final class ChatKnowledgeBindingValidator extends Object
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

  • 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; and
  • its topK equals the topK the owner's SEARCH entries declare, merged field by field over KnowledgeDeclarations.chatSearchDefaults() as the agent wires them.
Knowledge an AgentBuilder gives is layered into the same entries first, so it is checked the same way.
Since:
0.18.0
  • 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 install
      owner - the exact conversation owner
      ownerId - the owner's id, or null when the caller has none and the binding must name the owner object
      knowledge - the owner's knowledge entries; only the SEARCH ones in its chat scope count
      where - the declaration site, used in messages
      Throws:
      IllegalArgumentException - when the binding breaks the rule