Class Qwen3ChatTemplate

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

public final class Qwen3ChatTemplate extends Object implements ChatTemplate
Java port of the Qwen3 / Qwen3.5 / Qwen3.8 chat_template.jinja tool-calling path (XML <tool_call> format).

Reference: Hugging Face Qwen/Qwen3.8-27B chat template.

  • Constructor Details

    • Qwen3ChatTemplate

      public Qwen3ChatTemplate()
      Default template: open assistant turn, thinking enabled.
    • Qwen3ChatTemplate

      public Qwen3ChatTemplate(boolean addGenerationPrompt, boolean enableThinking)
      Creates a chat template with generation-prompt and thinking options.
      Parameters:
      addGenerationPrompt - when true, append open assistant header.
      enableThinking - when true, open with <think>\\n.
  • Method Details

    • 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.
    • encodeDialog

      public static String encodeDialog(Message[] dialog, ChatOptions options)
      Encodes dialog to a prompt string (generation prompt open).
      Parameters:
      dialog - conversation turns.
      options - chat options; may be null.
      Returns:
      prompt text.