Support OpenAI and Anthropic message processors - #9809
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Thanks @ezeli and @HGY19854338008 for raising #8327 and #9084 and providing concrete OpenAI tool-call examples — they were very helpful when shaping this change. This PR adds normalization for OpenAI @Jintao-Huang @hjh0119 @tastelikefeet, when convenient, we would also appreciate your guidance on whether |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
Thanks! I will check this code asap |
|
Hi @tastelikefeet, thank you again for the helpful review. The requested multimodal handling, documentation examples, and regression coverage have now been added, and the focused tests and pre-commit checks pass. When convenient, would you mind taking another look? We would really appreciate having this merged into |
What changed
assistant.tool_callsinto SWIFTtool_callmessagestool_useandtool_resultcontent blocks into SWIFT canonical rolesOpenAIMessagesPreprocessorandAnthropicMessagesPreprocessorclassesMessagesPreprocessorWhy
MessagesPreprocessor._check_messageskeeps onlyrole,content,loss, andloss_scale. OpenAI-style tool calls stored inassistant.tool_callswere therefore silently removed during dataset preprocessing even though templates can encode tool calls. This can produce training examples that retain assistant narration but lose the actual tool-call targets.Anthropic tool-use traces similarly need their content blocks expanded into SWIFT's canonical
assistant,tool_call, andtool_responseroles before template encoding.Impact
OpenAI and Anthropic agent traces can now be passed through the normal dataset preprocessing path without an external conversion script. Parallel OpenAI tool calls, string or object arguments, Anthropic text/tool interleaving, nested text tool results, and loss metadata are covered.
The regression test also decodes supervised labels and asserts that the tool name is present, rather than only checking that template encoding succeeds.
Validation
pre-commit run --all-filespython -m unittest tests.general.test_data_preprocess.TestProviderMessagesPreprocess tests.general.test_data_preprocess.TestRejectedMessagesPreprocess tests.general.test_data_preprocess.TestDataPreprocess.test_tool_messageRelated to #8327 and #9084.