Skip to content

Comments

chat: fix case where template accepts type content only#19419

Merged
ngxson merged 3 commits intoggml-org:masterfrom
ngxson:xsn/chat_fix_typed_content_only
Feb 9, 2026
Merged

chat: fix case where template accepts type content only#19419
ngxson merged 3 commits intoggml-org:masterfrom
ngxson:xsn/chat_fix_typed_content_only

Conversation

@ngxson
Copy link
Collaborator

@ngxson ngxson commented Feb 7, 2026

Fix chat template of PaddleOCR-VL, which requires content to be an array (see #18825)

This should be able to handle these case:

  • Template supports ONLY string content
  • Template supports ONLY array content
  • Template supports both string AND array content

@ngxson
Copy link
Collaborator Author

ngxson commented Feb 9, 2026

Pinging @pwilkin @aldehir @CISC if you can have a quick look on this (currently a roadblock for PaddleOCR). Thanks!

common/chat.cpp Outdated
}
});
}
printf("%s\n", jmsg.dump().c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove or convert to LOG_*

// Parses a JSON array of messages in OpenAI's chat completion API format.
std::vector<common_chat_msg> common_chat_msgs_parse_oaicompat(const nlohmann::ordered_json & messages);

// DEPRECATED: only used in tests
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be a good idea just to replace common_chat_msgs_to_json_oaicompat with the body of the new render_message_to_json (with the extended signature with full caps) and make the old common_chat_msgs_to_json_oaicompat call it with just the single cap set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I implemented in 6edb330 , test-chat is OK

@ngxson ngxson merged commit 98e57ca into ggml-org:master Feb 9, 2026
73 of 75 checks passed
liparetejas pushed a commit to liparetejas/llama.cpp that referenced this pull request Feb 23, 2026
* chat: fix case where template accepts type content only

* rm stray log

* reuse render_message_to_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jinja parser Issues related to the jinja parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants