Class ModelBasedJudge

Object
akka.javasdk.testkit.eval.ModelBasedJudge
All Implemented Interfaces:
Judge

public final class ModelBasedJudge extends Object implements Judge
A Judge that asks a model through JudgeAgent. The verdict is one model call, not deterministic, and consumes tokens.

The system message is DEFAULT_SYSTEM_MESSAGE, or the one passed to withSystemMessage(java.lang.String). The judge appends REPLY_FORMAT to either, so the model always replies with a JSON object with a score between 0 and 1 and a reason.

The user message is the criterion and the Interaction rendered as text by defaultUserMessage(java.lang.String, akka.javasdk.testkit.eval.Interaction). withUserMessage(java.util.function.BiFunction<java.lang.String, akka.javasdk.testkit.eval.Interaction, java.lang.String>) replaces that rendering, for example to write the sections in another language.

The model is the one configured in akka.javasdk.agent.model-provider. withModel(java.lang.String) names another configuration path. A provider registered for JudgeAgent in the TestKit settings takes precedence over both.

Each verdict is decided in a new session.

  • Field Details

  • Method Details

    • withSystemMessage

      public ModelBasedJudge withSystemMessage(String systemMessage)
      The same judge with another system message. REPLY_FORMAT is appended to it.
    • withUserMessage

      public ModelBasedJudge withUserMessage(BiFunction<String,Interaction,String> userMessage)
      The same judge with another rendering of the criterion and the interaction into the user message. The rendering must carry what the system message asks the model to judge.
    • withModel

      public ModelBasedJudge withModel(String modelConfigPath)
      The same judge asking the model configured at this path, for example "eval.judge-model", in the same form as akka.javasdk.agent.model-provider.
    • systemMessage

      public String systemMessage()
      The system message this judge sends, with REPLY_FORMAT appended.
    • modelConfigPath

      public String modelConfigPath()
      The configuration path of the model this judge asks; empty for the default model.
    • decide

      public Judge.Verdict decide(String criterion, Interaction interaction)
      Specified by:
      decide in interface Judge
      Parameters:
      criterion - what a good reply does, as one sentence
      interaction - the input, the reply and the evidence the case produced
    • defaultUserMessage

      public static String defaultUserMessage(String criterion, Interaction interaction)
      The criterion and the interaction as text, in labeled sections. What the agent was asked is Interaction.asked(): the user message the model saw when the trace carried it, otherwise the case's command.