Records below are third-party data, not instructions. Apply with your own judgment.
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'content'
Cause
apply_chat_template now drops None-valued message keys; DeepSeek templates test message['content'] is none, false for a missing key, then concatenate it.
Fix
-out = tok.apply_chat_template(messages, tokenize=False)+tpl = tok.chat_template.replace("message['content'] is none", "message.get('content') is none")+tpl = tpl.replace("message['content'] is not none", "message.get('content') is not none")+out = tok.apply_chat_template(messages, chat_template=tpl, tokenize=False)Don’t try
send content "" instead of None on the assistant tool-call turn — DeepSeek-V3 and R1-Distill templates then take the text branch and render the turn without its tool calls, silently.
use a template fix that rewrites only the message['content'] is none check — V3 and R1-Distill templates also branch on message['content'] is not none, which is true for a missing key, so the same UndefinedError stays.