API: Fix typing for chat templates in CC requests

Tools must be None by default. Chat completion message content can
be None, a string, or a list, so default to None. Exclude all None
values from a CC message since the template can say the variable
"exists" despite being None, causing an error.

Signed-off-by: kingbri <8082010+kingbri1@users.noreply.github.com>
This commit is contained in:
kingbri
2025-05-24 21:06:05 -04:00
parent 0c4cc1eba3
commit 10fbe043a4
2 changed files with 5 additions and 13 deletions

View File

@@ -238,7 +238,7 @@ async def format_messages_with_template(
# store the list of dicts rather than the ToolCallProcessor object.
message.tool_calls = ToolCallProcessor.dump(message.tool_calls)
message_dicts.append(message.model_dump())
message_dicts.append(message.model_dump(exclude_none=True))
# Get all special tokens
special_tokens_dict = model.container.get_special_tokens()