sendExtraContext function
The per-send extra_context JSON: extra with the thinking switch of
thinkingContext on top, so a template variable cannot turn thinking on
or off behind the caller's back.
Implementation
String sendExtraContext(bool enableThinking, Map<String, Object?>? extra) =>
extra == null || extra.isEmpty
? jsonEncode(thinkingContext(enableThinking))
: jsonEncode({...extra, ...thinkingContext(enableThinking)});