Class MiniMaxChatTemplate

java.lang.Object
smile.llm.template.MiniMaxChatTemplate
All Implemented Interfaces:
ChatTemplate

public final class MiniMaxChatTemplate extends Object implements ChatTemplate
Java port of the MiniMax-M3 chat_template.jinja: a system block with thinking instructions, a developer block (the user's system prompt and the tool list), then one block per turn, each introduced by ]~b] and closed by [e~[. Output is verified byte for byte against the Jinja template rendered by Hugging Face transformers.

Differences from the Jinja template, all because Message is not an arbitrary JSON object: the root role does not exist (the system prompt is always the developer block), assistant reasoning_content does not exist (reasoning is taken from <mm:think>...</mm:think> in the content), and <think>/</think> in assistant content, which is what this server returns to clients, are read as the MiniMax tags. As in the template, a system message that is not the first message is dropped.

  • Field Details

  • Constructor Details

    • MiniMaxChatTemplate

      public MiniMaxChatTemplate()
      Default template: open assistant turn, thinking mode unspecified (the model decides).
    • MiniMaxChatTemplate

      public MiniMaxChatTemplate(boolean addGenerationPrompt, String thinkingMode)
      Creates a template.
      Parameters:
      addGenerationPrompt - append the open assistant turn.
      thinkingMode - enabled, disabled, adaptive or null (undefined).
  • Method Details

    • forOptions

      public static MiniMaxChatTemplate forOptions(ChatOptions options)
      Creates the template for a request.
      Parameters:
      options - chat options; may be null.
      Returns:
      a template with an open assistant turn and the options' thinking mode.
    • encode

      public String encode(List<Message> dialog, ChatOptions options)
      Description copied from interface: ChatTemplate
      Encodes dialog messages with optional tool-calling options.
      Specified by:
      encode in interface ChatTemplate
      Parameters:
      dialog - ordered conversation turns.
      options - chat options; may be null.
      Returns:
      prompt text including an open assistant turn when applicable.