{% macro render_extra_keys(json_dict, handled_keys) %} {%- if json_dict is mapping %} {%- for json_key in json_dict if json_key not in handled_keys %} {%- if json_dict[json_key] is string %} {{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '' }} {%- else %} {{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson ) ~ '' }} {%- endif %} {%- endfor %} {%- endif %} {%- endmacro %} {%- macro render_content(content) %} {%- if content is string %} {{- content }} {%- elif content is iterable and content is not mapping %} {%- for item in content %} {%- if item is mapping %} {%- if 'text' in item %} {{- item.text }} {%- elif item.type == 'input_text' or item.type == 'output_text' %} {{- item.text | default('', true) }} {%- elif item.type == 'image' or item.type == 'image_url' or 'image_url' in item %} {{- '' }} {%- elif item.type == 'audio' or item.type == 'input_audio' %} {{- '