Class Qwen3ChatTemplate
java.lang.Object
smile.llm.template.Qwen3ChatTemplate
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionDefault template: open assistant turn, thinking enabled.Qwen3ChatTemplate(boolean addGenerationPrompt, boolean enableThinking) Creates a chat template with generation-prompt and thinking options. -
Method Summary
Modifier and TypeMethodDescriptionencode(List<Message> dialog, ChatOptions options) Encodes dialog messages with optional tool-calling options.static StringencodeDialog(Message[] dialog, ChatOptions options) Encodes dialog to a prompt string (generation prompt open).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChatTemplate
encode
-
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- whentrue, append open assistant header.enableThinking- whentrue, open with<think>\\n.
-
-
Method Details
-
encode
Description copied from interface:ChatTemplateEncodes dialog messages with optional tool-calling options.- Specified by:
encodein interfaceChatTemplate- Parameters:
dialog- ordered conversation turns.options- chat options; may benull.- Returns:
- prompt text including an open assistant turn when applicable.
-
encodeDialog
Encodes dialog to a prompt string (generation prompt open).- Parameters:
dialog- conversation turns.options- chat options; may benull.- Returns:
- prompt text.
-