Class SystemOneDecisionMapper

java.lang.Object
org.springframework.ai.systemone.SystemOneDecisionMapper

public final class SystemOneDecisionMapper extends Object
Maps a DecisionPrompt to a System One request and the response back to a DecisionResponse.

The input becomes the request state: a text as a string, fields as a JSON object in field order, a conversation as {"messages": [{"role", "content", ...}]} with tool calls and tool results as structured entries. System One decides about text, so media is rejected. Reasoning and unknown parts of a conversation message are not sent, since they are not the content under judgment, and a message with nothing else is left out; in a text or fields input they are rejected. A YesNoQuestion becomes a noul with its criteria, a ChoiceQuestion a choice and a ScoreQuestion a score whose levels carry their description as a structured criterion.

Shared by the decision models that talk to a System One endpoint through the TypeSafe SDK, such as SystemOneDecisionModel and the Ollama decision model.

Since:
2.1.0
Author:
Christian Tzolov, Thomas Vitale
  • Method Details

    • state

      public static org.springaicommunity.typesafe.JsonContent state(DecisionInput input)
      Map a decision input to the System One request state.
      Parameters:
      input - the decision input
      Returns:
      the request state
      Throws:
      IllegalArgumentException - if the input carries media or an unsupported part
    • questions

      public static Map<String,org.springaicommunity.typesafe.question.Question> questions(DecisionPrompt prompt)
      Map the questions of a decision prompt to System One questions, keeping their names and order.
      Parameters:
      prompt - the decision prompt
      Returns:
      the System One questions by name
    • question

      public static org.springaicommunity.typesafe.question.Question question(String name, DecisionQuestion question)
      Map a decision question to a System One question.
      Parameters:
      name - the name of the question
      question - the decision question
      Returns:
      the System One question
    • response

      public static DecisionResponse response(DecisionPrompt prompt, org.springaicommunity.typesafe.response.SystemOneResponse response)
      Map a System One response to a decision response for the given prompt.
      Parameters:
      prompt - the decision prompt the response answers
      response - the System One response
      Returns:
      the decision response
      Throws:
      IllegalStateException - if an answer does not fit its question