Class ChatTurn.Builder

java.lang.Object
com.tnsai.integration.scop.ChatTurn.Builder
Enclosing class:
ChatTurn

public static final class ChatTurn.Builder extends Object
Builds a ChatTurn. Each setter replaces what an earlier call to it set.
Since:
0.18.6
  • Method Details

    • tools

      public ChatTurn.Builder tools(org.json.JSONArray tools)
      Parameters:
      tools - provider-neutral tool declarations, or null for none
      Returns:
      this builder
    • owners

      public ChatTurn.Builder owners(Object... owners)
      The exact objects whose @State and chat knowledge apply, such as an agent followed by every @RoleSpec role it plays. Each owner is passed itself, not inside a Collection.
      Parameters:
      owners - the owners, in order; none for a plain dispatch
      Returns:
      this builder
      Throws:
      NullPointerException - if the array is null
    • owners

      public ChatTurn.Builder owners(List<?> owners)
      owners(Object...) from a list.
      Parameters:
      owners - the owners, in order; empty for a plain dispatch
      Returns:
      this builder
      Throws:
      NullPointerException - if the list is null
    • bindings

      public ChatTurn.Builder bindings(com.tnsai.rag.ChatKnowledgeBinding... bindings)
      Exact-owner-scoped live retrieval bindings: per listed owner at most one checked against its declarations and any number undeclared, no two of an owner searching the same source name, in any order. build() checks that each belongs to a listed owner; the rules among one owner's bindings are checked when the turn is sent. A turn without bindings leaves this out; a null binding is refused.
      Parameters:
      bindings - the bindings
      Returns:
      this builder
      Throws:
      NullPointerException - if the array is null
    • bindings

      public ChatTurn.Builder bindings(List<com.tnsai.rag.ChatKnowledgeBinding> bindings)
      Parameters:
      bindings - the bindings
      Returns:
      this builder
      Throws:
      NullPointerException - if the list is null
    • context

      public ChatTurn.Builder context(com.tnsai.rag.ChatRetrievalContext context)
      The immutable request-local scope and lifecycle context under which the owners' knowledge is given and searched.
      Parameters:
      context - the context, or null for no retrieval; a context needs at least one owner, as only owners have knowledge to retrieve
      Returns:
      this builder
    • requestSection

      public ChatTurn.Builder requestSection(String requestSection)
      A section the caller renders for this request alone, such as an agent's recent activity. It is added only to the outbound copy, at the end of the last system message and before any refreshed state, or as a new system message when there is none; its dynamic state markers are escaped.
      Parameters:
      requestSection - the section, or null or blank for none
      Returns:
      this builder
    • build

      public ChatTurn build()
      Returns:
      the turn
      Throws:
      NullPointerException - if an owner or a binding is null
      IllegalArgumentException - if an owner is a Collection or is listed twice, bindings or a retrieval context are given without owners, or a binding belongs to no listed owner