Class ScriptedChatModel.Builder

java.lang.Object
io.micronaut.langchain4j.test.ScriptedChatModel.Builder
Enclosing class:
ScriptedChatModel

public static final class ScriptedChatModel.Builder extends Object
Builds the rules of a ScriptedChatModel, evaluated in order.
Since:
2.4.0
  • Method Details

    • when

      public ScriptedChatModel.Answer when(Predicate<dev.langchain4j.model.chat.request.ChatRequest> condition)
      Parameters:
      condition - The condition of the rule
      Returns:
      The answer of the rule
    • whenUserMessageContains

      public ScriptedChatModel.Answer whenUserMessageContains(String text)
      Parameters:
      text - The text to look for
      Returns:
      The answer to the requests whose last user message contains the text
    • whenToolResult

      public ScriptedChatModel.Answer whenToolResult()
      Returns:
      The answer to the requests that end with the result of a tool execution
    • otherwise

      public ScriptedChatModel.Builder otherwise(String response)
      Parameters:
      response - The response to the requests that match no other rule
      Returns:
      The builder
    • otherwise

      public ScriptedChatModel.Builder otherwise(Function<dev.langchain4j.model.chat.request.ChatRequest, String> response)
      Parameters:
      response - The response to the requests that match no other rule
      Returns:
      The builder
    • build

      public ScriptedChatModel build()
      Returns:
      The chat model