serializeToolsForSdk static method
Serialize tools into the OpenAI Chat Completions JSON format that
LiteRT-LM SDK expects in litert_lm_conversation_config_set_tools.
SDK then applies chat_template.jinja (via minja) to render native
Gemma 4 <|tool>declaration:...<tool|> tokens.
Reference: upstream c/engine_test.cc::CreateConversationConfigWithTools.
Implementation
static String serializeToolsForSdk(List<Tool> tools) => jsonEncode([
for (final tool in tools)
{
'type': 'function',
'function': {
'name': tool.name,
'description': tool.description,
'parameters': tool.parameters,
},
},
]);