sendExtraContext function

String sendExtraContext(
  1. bool enableThinking,
  2. Map<String, Object?>? extra
)

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)});