-module(glopenai@response). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/glopenai/response.gleam"). -export([new_create_response/1, with_model/2, with_instructions/2, with_tools/2, with_temperature/2, with_max_output_tokens/2, with_stream/2, with_store/2, with_metadata/2, with_previous_response_id/2, with_reasoning/2, with_text/2, with_tool_choice/2, with_truncation/2, with_service_tier/2, with_top_p/2, with_include/2, with_conversation/2, with_background/2, message_phase_to_json/1, tool_search_execution_type_to_json/1, search_content_type_to_json/1, output_status_to_json/1, role_to_json/1, input_role_to_json/1, truncation_to_json/1, service_tier_to_json/1, response_status_to_json/1, verbosity_to_json/1, reasoning_summary_to_json/1, prompt_cache_retention_to_json/1, include_enum_to_json/1, web_search_context_size_to_json/1, image_gen_bg_to_json/1, image_gen_fmt_to_json/1, image_gen_quality_to_json/1, image_gen_size_to_json/1, input_fidelity_to_json/1, image_gen_moderation_to_json/1, image_gen_action_to_json/1, tool_choice_options_to_json/1, rank_version_type_to_json/1, reasoning_to_json/1, input_content_to_json/1, easy_input_content_to_json/1, easy_input_message_to_json/1, function_tool_to_json/1, web_search_tool_to_json/1, image_gen_tool_to_json/1, tool_to_json/1, text_response_format_to_json/1, response_text_param_to_json/1, tool_choice_param_to_json/1, conversation_param_to_json/1, prompt_to_json/1, response_stream_options_to_json/1, item_to_json/1, input_item_to_json/1, input_param_to_json/1, create_response_to_json/1, message_phase_decoder/0, output_status_decoder/0, role_decoder/0, input_role_decoder/0, service_tier_decoder/0, response_status_decoder/0, truncation_decoder/0, verbosity_decoder/0, reasoning_summary_decoder/0, prompt_cache_retention_decoder/0, reasoning_decoder/0, text_response_format_decoder/0, response_text_param_decoder/0, annotation_decoder/0, response_log_prob_decoder/0, output_text_content_decoder/0, output_message_content_decoder/0, output_content_decoder/0, summary_part_decoder/0, output_message_decoder/0, reasoning_item_decoder/0, function_tool_call_decoder/0, image_gen_tool_call_decoder/0, web_search_tool_call_decoder/0, file_search_tool_call_decoder/0, compaction_body_decoder/0, mcp_tool_call_decoder/0, custom_tool_call_decoder/0, output_item_decoder/0, conversation_decoder/0, error_object_decoder/0, prompt_decoder/0, response_decoder/0, response_stream_event_decoder/0, parse_stream_event/1, create_request/2, create_response_response/1, retrieve_request/2, retrieve_response/1, delete_request/2, delete_response/1, cancel_request/2, cancel_response/1, list_input_items_request/2, list_input_items_response/1, get_input_token_counts_request/2, get_input_token_counts_response/1, compact_request/2, compact_response/1]). -export_type([message_phase/0, tool_search_execution_type/0, search_content_type/0, function_call_status/0, output_status/0, role/0, input_role/0, truncation/0, service_tier/0, response_status/0, verbosity/0, reasoning_summary/0, prompt_cache_retention/0, file_search_tool_call_status/0, web_search_tool_call_status/0, web_search_tool_search_context_size/0, computer_environment/0, rank_version_type/0, image_gen_tool_background/0, image_gen_tool_output_format/0, image_gen_tool_quality/0, image_gen_tool_size/0, input_fidelity/0, image_gen_tool_moderation/0, image_gen_action_enum/0, tool_choice_options/0, tool_choice_allowed_mode/0, click_button_type/0, image_gen_tool_call_status/0, code_interpreter_tool_call_status/0, mcp_tool_call_status/0, function_shell_call_item_status/0, apply_patch_call_status_param/0, apply_patch_call_output_status_param/0, include_enum/0, input_text_content/0, input_image_content/0, input_file_content/0, input_content/0, output_text_content/0, refusal_content/0, reasoning_text_content/0, summary_text_content/0, output_message_content/0, output_content/0, summary_part/0, file_citation_body/0, url_citation_body/0, container_file_citation_body/0, file_path_annotation/0, annotation/0, response_top_log_prob/0, response_log_prob/0, output_message/0, input_message/0, easy_input_content/0, easy_input_message/0, message_item/0, item_reference/0, conversation/0, conversation_param/0, reasoning/0, response_text_param/0, text_response_format_configuration/0, function_tool_call/0, function_call_output_item_param/0, function_call_output/0, computer_call_safety_check_param/0, computer_screenshot_image/0, computer_call_output_item_param/0, file_search_tool_call_result/0, file_search_tool_call/0, web_search_action_search_source/0, web_search_action_search/0, web_search_action_open_page/0, web_search_action_find/0, web_search_tool_call_action/0, web_search_tool_call/0, click_param/0, double_click_action/0, coord_param/0, drag_param/0, key_press_action/0, move_param/0, scroll_param/0, type_action_param/0, computer_action/0, computer_tool_call/0, image_gen_tool_call/0, code_interpreter_output_logs/0, code_interpreter_output_image/0, code_interpreter_tool_call_output/0, code_interpreter_tool_call/0, local_shell_exec_action/0, local_shell_tool_call/0, local_shell_tool_call_output/0, reasoning_item/0, compaction_summary_item_param/0, compaction_body/0, mcp_tool_call/0, mcp_list_tools/0, mcp_approval_request/0, mcp_approval_response/0, function_shell_action_param/0, local_environment_param/0, container_reference_param/0, container_reference_resource/0, function_shell_call_item_environment/0, function_shell_call_item_param/0, function_shell_call_output_exit_outcome_param/0, function_shell_call_output_outcome_param/0, function_shell_call_output_content_param/0, function_shell_call_output_item_param/0, function_shell_action/0, function_shell_call_environment/0, function_shell_call_output_exit_outcome/0, function_shell_call_output_outcome/0, function_shell_call_output_content/0, function_shell_call/0, function_shell_call_output/0, apply_patch_create_file_operation_param/0, apply_patch_delete_file_operation_param/0, apply_patch_update_file_operation_param/0, apply_patch_operation_param/0, apply_patch_tool_call_item_param/0, apply_patch_tool_call_output_item_param/0, apply_patch_create_file_operation/0, apply_patch_delete_file_operation/0, apply_patch_update_file_operation/0, apply_patch_operation/0, apply_patch_tool_call/0, apply_patch_tool_call_output/0, custom_tool_call_output_output/0, custom_tool_call_output/0, custom_tool_call/0, tool_search_call/0, tool_search_call_item_param/0, tool_search_output/0, tool_search_output_item_param/0, function_tool/0, hybrid_search/0, ranking_options/0, file_search_tool/0, web_search_tool_filters/0, web_search_approximate_location/0, web_search_tool/0, computer_use_preview_tool/0, code_interpreter_container_auto/0, code_interpreter_tool_container/0, code_interpreter_tool/0, image_gen_tool_input_image_mask/0, image_gen_tool/0, tool_search_tool_param/0, function_tool_param/0, custom_tool_param_format/0, custom_tool_param/0, namespace_tool_param_tool/0, namespace_tool_param/0, container_auto_param/0, function_shell_environment/0, function_shell_tool_param/0, tool/0, tool_choice_allowed/0, tool_choice_function/0, tool_choice_mcp/0, tool_choice_custom/0, tool_choice_types/0, tool_choice_param/0, item/0, input_item/0, input_param/0, output_item/0, prompt/0, billing/0, error_object/0, incomplete_details/0, response_stream_options/0, instructions/0, create_response/0, response/0, delete_response/0, response_item_list/0, token_counts_resource/0, compact_resource/0, response_stream_event/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type message_phase() :: commentary | final_answer. -type tool_search_execution_type() :: execution_server | execution_client. -type search_content_type() :: search_text | search_image. -type function_call_status() :: function_call_in_progress | function_call_completed | function_call_incomplete. -type output_status() :: output_in_progress | output_completed | output_incomplete. -type role() :: role_user | role_assistant | role_system | role_developer. -type input_role() :: input_role_user | input_role_system | input_role_developer. -type truncation() :: truncation_auto | truncation_disabled. -type service_tier() :: service_tier_auto | service_tier_default | service_tier_flex | service_tier_scale | service_tier_priority. -type response_status() :: status_completed | status_failed | status_in_progress | status_cancelled | status_queued | status_incomplete. -type verbosity() :: verbosity_low | verbosity_medium | verbosity_high. -type reasoning_summary() :: reasoning_summary_auto | reasoning_summary_concise | reasoning_summary_detailed. -type prompt_cache_retention() :: prompt_cache_in_memory | prompt_cache_hours24. -type file_search_tool_call_status() :: file_search_in_progress | file_search_searching | file_search_incomplete | file_search_failed | file_search_completed. -type web_search_tool_call_status() :: web_search_in_progress | web_search_searching | web_search_completed | web_search_failed. -type web_search_tool_search_context_size() :: web_search_context_low | web_search_context_medium | web_search_context_high. -type computer_environment() :: environment_windows | environment_mac | environment_linux | environment_ubuntu | environment_browser. -type rank_version_type() :: rank_auto | rank_default20241115. -type image_gen_tool_background() :: image_gen_bg_transparent | image_gen_bg_opaque | image_gen_bg_auto. -type image_gen_tool_output_format() :: image_gen_fmt_png | image_gen_fmt_webp | image_gen_fmt_jpeg. -type image_gen_tool_quality() :: image_gen_quality_low | image_gen_quality_medium | image_gen_quality_high | image_gen_quality_auto. -type image_gen_tool_size() :: image_gen_size_auto | image_gen_size1024x1024 | image_gen_size1024x1536 | image_gen_size1536x1024. -type input_fidelity() :: fidelity_high | fidelity_low. -type image_gen_tool_moderation() :: image_gen_moderation_auto | image_gen_moderation_low. -type image_gen_action_enum() :: image_gen_generate | image_gen_edit | image_gen_action_auto. -type tool_choice_options() :: tool_choice_none | tool_choice_auto | tool_choice_required. -type tool_choice_allowed_mode() :: allowed_mode_auto | allowed_mode_required. -type click_button_type() :: click_left | click_right | click_wheel | click_back | click_forward. -type image_gen_tool_call_status() :: image_gen_call_in_progress | image_gen_call_completed | image_gen_call_generating | image_gen_call_failed. -type code_interpreter_tool_call_status() :: code_interp_in_progress | code_interp_completed | code_interp_incomplete | code_interp_interpreting | code_interp_failed. -type mcp_tool_call_status() :: mcp_call_in_progress | mcp_call_completed | mcp_call_incomplete | mcp_call_calling | mcp_call_failed. -type function_shell_call_item_status() :: shell_item_in_progress | shell_item_completed | shell_item_incomplete. -type apply_patch_call_status_param() :: apply_patch_in_progress | apply_patch_completed. -type apply_patch_call_output_status_param() :: apply_patch_output_completed | apply_patch_output_failed. -type include_enum() :: include_file_search_call_results | include_web_search_call_results | include_web_search_call_action_sources | include_message_input_image_image_url | include_computer_call_output_output_image_url | include_code_interpreter_call_outputs | include_reasoning_encrypted_content | include_message_output_text_logprobs. -type input_text_content() :: {input_text_content, binary()}. -type input_image_content() :: {input_image_content, glopenai@shared:image_detail(), gleam@option:option(binary()), gleam@option:option(binary())}. -type input_file_content() :: {input_file_content, gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary())}. -type input_content() :: {content_input_text, input_text_content()} | {content_input_image, input_image_content()} | {content_input_file, input_file_content()}. -type output_text_content() :: {output_text_content, list(annotation()), gleam@option:option(list(response_log_prob())), binary()}. -type refusal_content() :: {refusal_content, binary()}. -type reasoning_text_content() :: {reasoning_text_content, binary()}. -type summary_text_content() :: {summary_text_content, binary()}. -type output_message_content() :: {output_message_output_text, output_text_content()} | {output_message_refusal, refusal_content()}. -type output_content() :: {output_content_output_text, output_text_content()} | {output_content_refusal, refusal_content()} | {output_content_reasoning_text, reasoning_text_content()}. -type summary_part() :: {summary_part_summary_text, summary_text_content()}. -type file_citation_body() :: {file_citation_body, binary(), binary(), integer()}. -type url_citation_body() :: {url_citation_body, integer(), integer(), binary(), binary()}. -type container_file_citation_body() :: {container_file_citation_body, binary(), integer(), binary(), binary(), integer()}. -type file_path_annotation() :: {file_path_annotation, binary(), integer()}. -type annotation() :: {annotation_file_citation, file_citation_body()} | {annotation_url_citation, url_citation_body()} | {annotation_container_file_citation, container_file_citation_body()} | {annotation_file_path, file_path_annotation()}. -type response_top_log_prob() :: {response_top_log_prob, float(), binary()}. -type response_log_prob() :: {response_log_prob, float(), binary(), list(response_top_log_prob())}. -type output_message() :: {output_message, list(output_message_content()), binary(), role(), gleam@option:option(message_phase()), output_status()}. -type input_message() :: {input_message, list(input_content()), input_role(), gleam@option:option(output_status())}. -type easy_input_content() :: {easy_content_text, binary()} | {easy_content_list, list(input_content())}. -type easy_input_message() :: {easy_input_message, role(), easy_input_content(), gleam@option:option(message_phase())}. -type message_item() :: {message_item_output, output_message()} | {message_item_input, input_message()}. -type item_reference() :: {item_reference, gleam@option:option(binary()), binary()}. -type conversation() :: {conversation, binary()}. -type conversation_param() :: {conversation_id, binary()} | {conversation_object, conversation()}. -type reasoning() :: {reasoning, gleam@option:option(glopenai@shared:reasoning_effort()), gleam@option:option(reasoning_summary())}. -type response_text_param() :: {response_text_param, text_response_format_configuration(), gleam@option:option(verbosity())}. -type text_response_format_configuration() :: text_format_text | text_format_json_object | {text_format_json_schema, glopenai@shared:response_format_json_schema()}. -type function_tool_call() :: {function_tool_call, binary(), binary(), gleam@option:option(binary()), binary(), gleam@option:option(binary()), gleam@option:option(output_status())}. -type function_call_output_item_param() :: {function_call_output_item_param, binary(), function_call_output(), gleam@option:option(binary()), gleam@option:option(output_status())}. -type function_call_output() :: {function_call_output_text, binary()} | {function_call_output_content, list(input_content())}. -type computer_call_safety_check_param() :: {computer_call_safety_check_param, binary(), gleam@option:option(binary()), gleam@option:option(binary())}. -type computer_screenshot_image() :: {computer_screenshot_image, gleam@option:option(binary()), gleam@option:option(binary())}. -type computer_call_output_item_param() :: {computer_call_output_item_param, binary(), computer_screenshot_image(), gleam@option:option(list(computer_call_safety_check_param())), gleam@option:option(binary()), gleam@option:option(output_status())}. -type file_search_tool_call_result() :: {file_search_tool_call_result, gleam@dynamic:dynamic_(), binary(), binary(), float(), binary()}. -type file_search_tool_call() :: {file_search_tool_call, binary(), list(binary()), file_search_tool_call_status(), gleam@option:option(list(file_search_tool_call_result()))}. -type web_search_action_search_source() :: {web_search_action_search_source, binary(), binary()}. -type web_search_action_search() :: {web_search_action_search, binary(), gleam@option:option(list(web_search_action_search_source()))}. -type web_search_action_open_page() :: {web_search_action_open_page, gleam@option:option(binary())}. -type web_search_action_find() :: {web_search_action_find, binary(), binary()}. -type web_search_tool_call_action() :: {web_search_action_search_variant, web_search_action_search()} | {web_search_action_open_page_variant, web_search_action_open_page()} | {web_search_action_find_variant, web_search_action_find()} | {web_search_action_find_in_page_variant, web_search_action_find()}. -type web_search_tool_call() :: {web_search_tool_call, web_search_tool_call_action(), binary(), web_search_tool_call_status()}. -type click_param() :: {click_param, click_button_type(), integer(), integer()}. -type double_click_action() :: {double_click_action, integer(), integer()}. -type coord_param() :: {coord_param, integer(), integer()}. -type drag_param() :: {drag_param, list(coord_param())}. -type key_press_action() :: {key_press_action, list(binary())}. -type move_param() :: {move_param, integer(), integer()}. -type scroll_param() :: {scroll_param, integer(), integer(), integer(), integer()}. -type type_action_param() :: {type_action_param, binary()}. -type computer_action() :: {computer_click, click_param()} | {computer_double_click, double_click_action()} | {computer_drag, drag_param()} | {computer_keypress, key_press_action()} | {computer_move, move_param()} | computer_screenshot | {computer_scroll, scroll_param()} | {computer_type, type_action_param()} | computer_wait. -type computer_tool_call() :: {computer_tool_call, gleam@option:option(computer_action()), gleam@option:option(list(computer_action())), binary(), binary(), list(computer_call_safety_check_param()), output_status()}. -type image_gen_tool_call() :: {image_gen_tool_call, binary(), gleam@option:option(binary()), image_gen_tool_call_status()}. -type code_interpreter_output_logs() :: {code_interpreter_output_logs, binary()}. -type code_interpreter_output_image() :: {code_interpreter_output_image, binary()}. -type code_interpreter_tool_call_output() :: {code_interp_output_logs, code_interpreter_output_logs()} | {code_interp_output_image, code_interpreter_output_image()}. -type code_interpreter_tool_call() :: {code_interpreter_tool_call, gleam@option:option(binary()), binary(), binary(), gleam@option:option(list(code_interpreter_tool_call_output())), code_interpreter_tool_call_status()}. -type local_shell_exec_action() :: {local_shell_exec_action, list(binary()), gleam@dict:dict(binary(), binary()), gleam@option:option(integer()), gleam@option:option(binary()), gleam@option:option(binary())}. -type local_shell_tool_call() :: {local_shell_tool_call, local_shell_exec_action(), binary(), binary(), output_status()}. -type local_shell_tool_call_output() :: {local_shell_tool_call_output, binary(), binary(), gleam@option:option(output_status())}. -type reasoning_item() :: {reasoning_item, binary(), list(summary_part()), gleam@option:option(list(reasoning_text_content())), gleam@option:option(binary()), gleam@option:option(output_status())}. -type compaction_summary_item_param() :: {compaction_summary_item_param, gleam@option:option(binary()), binary()}. -type compaction_body() :: {compaction_body, binary(), binary(), gleam@option:option(binary())}. -type mcp_tool_call() :: {mcp_tool_call, binary(), binary(), binary(), binary(), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(mcp_tool_call_status())}. -type mcp_list_tools() :: {mcp_list_tools, binary(), binary(), gleam@dynamic:dynamic_(), gleam@option:option(binary())}. -type mcp_approval_request() :: {mcp_approval_request, binary(), binary(), binary(), binary()}. -type mcp_approval_response() :: {mcp_approval_response, binary(), boolean(), gleam@option:option(binary()), gleam@option:option(binary())}. -type function_shell_action_param() :: {function_shell_action_param, list(binary()), gleam@option:option(integer()), gleam@option:option(integer())}. -type local_environment_param() :: {local_environment_param, gleam@option:option(gleam@dynamic:dynamic_())}. -type container_reference_param() :: {container_reference_param, binary()}. -type container_reference_resource() :: {container_reference_resource, binary()}. -type function_shell_call_item_environment() :: {shell_env_local, local_environment_param()} | {shell_env_container_reference, container_reference_param()}. -type function_shell_call_item_param() :: {function_shell_call_item_param, gleam@option:option(binary()), binary(), function_shell_action_param(), gleam@option:option(function_shell_call_item_status()), gleam@option:option(function_shell_call_item_environment())}. -type function_shell_call_output_exit_outcome_param() :: {function_shell_call_output_exit_outcome_param, integer()}. -type function_shell_call_output_outcome_param() :: shell_outcome_timeout | {shell_outcome_exit, function_shell_call_output_exit_outcome_param()}. -type function_shell_call_output_content_param() :: {function_shell_call_output_content_param, binary(), binary(), function_shell_call_output_outcome_param()}. -type function_shell_call_output_item_param() :: {function_shell_call_output_item_param, gleam@option:option(binary()), binary(), list(function_shell_call_output_content_param()), gleam@option:option(integer())}. -type function_shell_action() :: {function_shell_action, list(binary()), gleam@option:option(integer()), gleam@option:option(integer())}. -type function_shell_call_environment() :: shell_call_env_local | {shell_call_env_container_reference, container_reference_resource()}. -type function_shell_call_output_exit_outcome() :: {function_shell_call_output_exit_outcome, integer()}. -type function_shell_call_output_outcome() :: shell_call_outcome_timeout | {shell_call_outcome_exit, function_shell_call_output_exit_outcome()}. -type function_shell_call_output_content() :: {function_shell_call_output_content, binary(), binary(), function_shell_call_output_outcome(), gleam@option:option(binary())}. -type function_shell_call() :: {function_shell_call, binary(), binary(), function_shell_action(), function_shell_call_item_status(), gleam@option:option(function_shell_call_environment()), gleam@option:option(binary())}. -type function_shell_call_output() :: {function_shell_call_output, binary(), binary(), list(function_shell_call_output_content()), gleam@option:option(integer()), gleam@option:option(binary())}. -type apply_patch_create_file_operation_param() :: {apply_patch_create_file_operation_param, binary(), binary()}. -type apply_patch_delete_file_operation_param() :: {apply_patch_delete_file_operation_param, binary()}. -type apply_patch_update_file_operation_param() :: {apply_patch_update_file_operation_param, binary(), binary()}. -type apply_patch_operation_param() :: {apply_patch_op_create_file, apply_patch_create_file_operation_param()} | {apply_patch_op_delete_file, apply_patch_delete_file_operation_param()} | {apply_patch_op_update_file, apply_patch_update_file_operation_param()}. -type apply_patch_tool_call_item_param() :: {apply_patch_tool_call_item_param, gleam@option:option(binary()), binary(), apply_patch_call_status_param(), apply_patch_operation_param()}. -type apply_patch_tool_call_output_item_param() :: {apply_patch_tool_call_output_item_param, gleam@option:option(binary()), binary(), apply_patch_call_output_status_param(), gleam@option:option(binary())}. -type apply_patch_create_file_operation() :: {apply_patch_create_file_operation, binary(), binary()}. -type apply_patch_delete_file_operation() :: {apply_patch_delete_file_operation, binary()}. -type apply_patch_update_file_operation() :: {apply_patch_update_file_operation, binary(), binary()}. -type apply_patch_operation() :: {apply_patch_create_file, apply_patch_create_file_operation()} | {apply_patch_delete_file, apply_patch_delete_file_operation()} | {apply_patch_update_file, apply_patch_update_file_operation()}. -type apply_patch_tool_call() :: {apply_patch_tool_call, binary(), binary(), apply_patch_call_status_param(), apply_patch_operation(), gleam@option:option(binary())}. -type apply_patch_tool_call_output() :: {apply_patch_tool_call_output, binary(), binary(), apply_patch_call_output_status_param(), gleam@option:option(binary()), gleam@option:option(binary())}. -type custom_tool_call_output_output() :: {custom_tool_call_output_text, binary()} | {custom_tool_call_output_list, list(input_content())}. -type custom_tool_call_output() :: {custom_tool_call_output, binary(), custom_tool_call_output_output(), gleam@option:option(binary())}. -type custom_tool_call() :: {custom_tool_call, binary(), gleam@option:option(binary()), binary(), binary(), binary()}. -type tool_search_call() :: {tool_search_call, binary(), gleam@option:option(binary()), tool_search_execution_type(), gleam@dynamic:dynamic_(), function_call_status(), gleam@option:option(binary())}. -type tool_search_call_item_param() :: {tool_search_call_item_param, gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(tool_search_execution_type()), gleam@dynamic:dynamic_(), gleam@option:option(output_status())}. -type tool_search_output() :: {tool_search_output, binary(), gleam@option:option(binary()), tool_search_execution_type(), gleam@dynamic:dynamic_(), function_call_status(), gleam@option:option(binary())}. -type tool_search_output_item_param() :: {tool_search_output_item_param, gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(tool_search_execution_type()), gleam@dynamic:dynamic_(), gleam@option:option(output_status())}. -type function_tool() :: {function_tool, binary(), gleam@option:option(gleam@dynamic:dynamic_()), gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(boolean())}. -type hybrid_search() :: {hybrid_search, float(), float()}. -type ranking_options() :: {ranking_options, gleam@option:option(hybrid_search()), rank_version_type(), gleam@option:option(float())}. -type file_search_tool() :: {file_search_tool, list(binary()), gleam@option:option(integer()), gleam@option:option(gleam@dynamic:dynamic_()), gleam@option:option(ranking_options())}. -type web_search_tool_filters() :: {web_search_tool_filters, gleam@option:option(list(binary()))}. -type web_search_approximate_location() :: {web_search_approximate_location, gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary()), gleam@option:option(binary())}. -type web_search_tool() :: {web_search_tool, gleam@option:option(web_search_tool_filters()), gleam@option:option(web_search_approximate_location()), gleam@option:option(web_search_tool_search_context_size()), gleam@option:option(list(search_content_type()))}. -type computer_use_preview_tool() :: {computer_use_preview_tool, computer_environment(), integer(), integer()}. -type code_interpreter_container_auto() :: {code_interpreter_container_auto, gleam@option:option(list(binary())), gleam@option:option(integer())}. -type code_interpreter_tool_container() :: {code_interp_container_auto, code_interpreter_container_auto()} | {code_interp_container_id, binary()}. -type code_interpreter_tool() :: {code_interpreter_tool, code_interpreter_tool_container()}. -type image_gen_tool_input_image_mask() :: {image_gen_tool_input_image_mask, gleam@option:option(binary()), gleam@option:option(binary())}. -type image_gen_tool() :: {image_gen_tool, gleam@option:option(image_gen_tool_background()), gleam@option:option(input_fidelity()), gleam@option:option(image_gen_tool_input_image_mask()), gleam@option:option(binary()), gleam@option:option(image_gen_tool_moderation()), gleam@option:option(integer()), gleam@option:option(image_gen_tool_output_format()), gleam@option:option(integer()), gleam@option:option(image_gen_tool_quality()), gleam@option:option(image_gen_tool_size()), gleam@option:option(image_gen_action_enum())}. -type tool_search_tool_param() :: {tool_search_tool_param, gleam@option:option(tool_search_execution_type()), gleam@option:option(binary()), gleam@option:option(gleam@dynamic:dynamic_())}. -type function_tool_param() :: {function_tool_param, binary(), gleam@option:option(binary()), gleam@option:option(gleam@dynamic:dynamic_()), gleam@option:option(boolean()), gleam@option:option(boolean())}. -type custom_tool_param_format() :: custom_format_text | {custom_format_grammar, gleam@dynamic:dynamic_()}. -type custom_tool_param() :: {custom_tool_param, binary(), gleam@option:option(binary()), custom_tool_param_format(), gleam@option:option(boolean())}. -type namespace_tool_param_tool() :: {namespace_function, function_tool_param()} | {namespace_custom, custom_tool_param()}. -type namespace_tool_param() :: {namespace_tool_param, binary(), binary(), list(namespace_tool_param_tool())}. -type container_auto_param() :: {container_auto_param, gleam@option:option(list(binary())), gleam@option:option(gleam@dynamic:dynamic_()), gleam@option:option(gleam@dynamic:dynamic_())}. -type function_shell_environment() :: {function_shell_env_container_auto, container_auto_param()} | {function_shell_env_local, local_environment_param()} | {function_shell_env_container_reference, container_reference_param()}. -type function_shell_tool_param() :: {function_shell_tool_param, gleam@option:option(function_shell_environment())}. -type tool() :: {tool_function, function_tool()} | {tool_file_search, file_search_tool()} | {tool_computer_use_preview, computer_use_preview_tool()} | {tool_web_search, web_search_tool()} | {tool_web_search20250826, web_search_tool()} | {tool_mcp, gleam@dynamic:dynamic_()} | {tool_code_interpreter, code_interpreter_tool()} | {tool_image_generation, image_gen_tool()} | tool_local_shell | {tool_shell, function_shell_tool_param()} | {tool_custom, custom_tool_param()} | tool_computer | {tool_namespace, namespace_tool_param()} | {tool_tool_search, tool_search_tool_param()} | {tool_web_search_preview, web_search_tool()} | {tool_web_search_preview20250311, web_search_tool()} | tool_apply_patch. -type tool_choice_allowed() :: {tool_choice_allowed, tool_choice_allowed_mode(), gleam@dynamic:dynamic_()}. -type tool_choice_function() :: {tool_choice_function, binary()}. -type tool_choice_mcp() :: {tool_choice_mcp, binary(), binary()}. -type tool_choice_custom() :: {tool_choice_custom, binary()}. -type tool_choice_types() :: tool_choice_file_search | tool_choice_web_search_preview | tool_choice_computer | tool_choice_computer_use_preview | tool_choice_computer_use | tool_choice_web_search_preview20250311 | tool_choice_code_interpreter | tool_choice_image_generation. -type tool_choice_param() :: {tool_choice_param_allowed_tools, tool_choice_allowed()} | {tool_choice_param_function, tool_choice_function()} | {tool_choice_param_mcp, tool_choice_mcp()} | {tool_choice_param_custom, tool_choice_custom()} | tool_choice_param_apply_patch | tool_choice_param_shell | {tool_choice_param_hosted, tool_choice_types()} | {tool_choice_param_mode, tool_choice_options()}. -type item() :: {item_message, message_item()} | {item_file_search_call, file_search_tool_call()} | {item_computer_call, computer_tool_call()} | {item_computer_call_output, computer_call_output_item_param()} | {item_web_search_call, web_search_tool_call()} | {item_function_call, function_tool_call()} | {item_function_call_output, function_call_output_item_param()} | {item_tool_search_call, tool_search_call_item_param()} | {item_tool_search_output, tool_search_output_item_param()} | {item_reasoning, reasoning_item()} | {item_compaction, compaction_summary_item_param()} | {item_image_generation_call, image_gen_tool_call()} | {item_code_interpreter_call, code_interpreter_tool_call()} | {item_local_shell_call, local_shell_tool_call()} | {item_local_shell_call_output, local_shell_tool_call_output()} | {item_shell_call, function_shell_call_item_param()} | {item_shell_call_output, function_shell_call_output_item_param()} | {item_apply_patch_call, apply_patch_tool_call_item_param()} | {item_apply_patch_call_output, apply_patch_tool_call_output_item_param()} | {item_mcp_list_tools, mcp_list_tools()} | {item_mcp_approval_request, mcp_approval_request()} | {item_mcp_approval_response, mcp_approval_response()} | {item_mcp_call, mcp_tool_call()} | {item_custom_tool_call_output, custom_tool_call_output()} | {item_custom_tool_call, custom_tool_call()}. -type input_item() :: {input_item_reference, item_reference()} | {input_item_item, item()} | {input_item_easy_message, easy_input_message()}. -type input_param() :: {input_text, binary()} | {input_items, list(input_item())}. -type output_item() :: {output_item_message, output_message()} | {output_item_file_search_call, file_search_tool_call()} | {output_item_function_call, function_tool_call()} | {output_item_web_search_call, web_search_tool_call()} | {output_item_computer_call, computer_tool_call()} | {output_item_reasoning, reasoning_item()} | {output_item_compaction, compaction_body()} | {output_item_image_generation_call, image_gen_tool_call()} | {output_item_code_interpreter_call, code_interpreter_tool_call()} | {output_item_local_shell_call, local_shell_tool_call()} | {output_item_shell_call, function_shell_call()} | {output_item_shell_call_output, function_shell_call_output()} | {output_item_apply_patch_call, apply_patch_tool_call()} | {output_item_apply_patch_call_output, apply_patch_tool_call_output()} | {output_item_mcp_call, mcp_tool_call()} | {output_item_mcp_list_tools, mcp_list_tools()} | {output_item_mcp_approval_request, mcp_approval_request()} | {output_item_custom_tool_call, custom_tool_call()} | {output_item_tool_search_call, tool_search_call()} | {output_item_tool_search_output, tool_search_output()}. -type prompt() :: {prompt, binary(), gleam@option:option(binary()), gleam@option:option(gleam@dynamic:dynamic_())}. -type billing() :: {billing, binary()}. -type error_object() :: {error_object, binary(), binary()}. -type incomplete_details() :: {incomplete_details, binary()}. -type response_stream_options() :: {response_stream_options, gleam@option:option(boolean())}. -type instructions() :: {instructions_text, binary()} | {instructions_array, list(input_item())}. -type create_response() :: {create_response, gleam@option:option(boolean()), gleam@option:option(conversation_param()), gleam@option:option(list(include_enum())), input_param(), gleam@option:option(binary()), gleam@option:option(integer()), gleam@option:option(integer()), gleam@option:option(gleam@dict:dict(binary(), binary())), gleam@option:option(binary()), gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(prompt()), gleam@option:option(binary()), gleam@option:option(prompt_cache_retention()), gleam@option:option(reasoning()), gleam@option:option(binary()), gleam@option:option(service_tier()), gleam@option:option(boolean()), gleam@option:option(boolean()), gleam@option:option(response_stream_options()), gleam@option:option(float()), gleam@option:option(response_text_param()), gleam@option:option(tool_choice_param()), gleam@option:option(list(tool())), gleam@option:option(integer()), gleam@option:option(float()), gleam@option:option(truncation())}. -type response() :: {response, gleam@option:option(boolean()), gleam@option:option(billing()), gleam@option:option(conversation()), integer(), gleam@option:option(integer()), gleam@option:option(error_object()), binary(), gleam@option:option(incomplete_details()), gleam@option:option(instructions()), gleam@option:option(integer()), gleam@option:option(gleam@dict:dict(binary(), binary())), binary(), binary(), list(output_item()), gleam@option:option(boolean()), gleam@option:option(binary()), gleam@option:option(prompt()), gleam@option:option(binary()), gleam@option:option(prompt_cache_retention()), gleam@option:option(reasoning()), gleam@option:option(binary()), gleam@option:option(service_tier()), response_status(), gleam@option:option(float()), gleam@option:option(response_text_param()), gleam@option:option(tool_choice_param()), gleam@option:option(list(tool())), gleam@option:option(integer()), gleam@option:option(float()), gleam@option:option(truncation()), gleam@option:option(glopenai@shared:response_usage())}. -type delete_response() :: {delete_response, binary(), boolean(), binary()}. -type response_item_list() :: {response_item_list, binary(), gleam@option:option(binary()), gleam@option:option(binary()), boolean(), gleam@dynamic:dynamic_()}. -type token_counts_resource() :: {token_counts_resource, binary(), integer()}. -type compact_resource() :: {compact_resource, binary(), binary(), list(output_item()), integer(), glopenai@shared:response_usage()}. -type response_stream_event() :: {event_response_created, integer(), response()} | {event_response_in_progress, integer(), response()} | {event_response_completed, integer(), response()} | {event_response_failed, integer(), response()} | {event_response_incomplete, integer(), response()} | {event_response_queued, integer(), response()} | {event_response_output_item_added, integer(), integer(), output_item()} | {event_response_output_item_done, integer(), integer(), output_item()} | {event_response_content_part_added, integer(), binary(), integer(), integer(), output_content()} | {event_response_content_part_done, integer(), binary(), integer(), integer(), output_content()} | {event_response_output_text_delta, integer(), binary(), integer(), integer(), binary(), gleam@option:option(list(response_log_prob()))} | {event_response_output_text_done, integer(), binary(), integer(), integer(), binary(), gleam@option:option(list(response_log_prob()))} | {event_response_refusal_delta, integer(), binary(), integer(), integer(), binary()} | {event_response_refusal_done, integer(), binary(), integer(), integer(), binary()} | {event_response_function_call_arguments_delta, integer(), binary(), integer(), binary()} | {event_response_function_call_arguments_done, gleam@option:option(binary()), integer(), binary(), integer(), binary()} | {event_response_file_search_call_in_progress, integer(), integer(), binary()} | {event_response_file_search_call_searching, integer(), integer(), binary()} | {event_response_file_search_call_completed, integer(), integer(), binary()} | {event_response_web_search_call_in_progress, integer(), integer(), binary()} | {event_response_web_search_call_searching, integer(), integer(), binary()} | {event_response_web_search_call_completed, integer(), integer(), binary()} | {event_response_reasoning_summary_part_added, integer(), binary(), integer(), integer(), summary_part()} | {event_response_reasoning_summary_part_done, integer(), binary(), integer(), integer(), summary_part()} | {event_response_reasoning_summary_text_delta, integer(), binary(), integer(), integer(), binary()} | {event_response_reasoning_summary_text_done, integer(), binary(), integer(), integer(), binary()} | {event_response_reasoning_text_delta, integer(), binary(), integer(), integer(), binary()} | {event_response_reasoning_text_done, integer(), binary(), integer(), integer(), binary()} | {event_response_image_gen_call_completed, integer(), integer(), binary()} | {event_response_image_gen_call_generating, integer(), integer(), binary()} | {event_response_image_gen_call_in_progress, integer(), integer(), binary()} | {event_response_image_gen_call_partial_image, integer(), integer(), binary(), integer(), binary()} | {event_response_mcp_call_arguments_delta, integer(), integer(), binary(), binary()} | {event_response_mcp_call_arguments_done, integer(), integer(), binary(), binary()} | {event_response_mcp_call_completed, integer(), integer(), binary()} | {event_response_mcp_call_failed, integer(), integer(), binary()} | {event_response_mcp_call_in_progress, integer(), integer(), binary()} | {event_response_mcp_list_tools_completed, integer(), integer(), binary()} | {event_response_mcp_list_tools_failed, integer(), integer(), binary()} | {event_response_mcp_list_tools_in_progress, integer(), integer(), binary()} | {event_response_code_interpreter_call_in_progress, integer(), integer(), binary()} | {event_response_code_interpreter_call_interpreting, integer(), integer(), binary()} | {event_response_code_interpreter_call_completed, integer(), integer(), binary()} | {event_response_code_interpreter_call_code_delta, integer(), integer(), binary(), binary()} | {event_response_code_interpreter_call_code_done, integer(), integer(), binary(), binary()} | {event_response_output_text_annotation_added, integer(), integer(), integer(), integer(), binary(), gleam@dynamic:dynamic_()} | {event_response_custom_tool_call_input_delta, integer(), integer(), binary(), binary()} | {event_response_custom_tool_call_input_done, integer(), integer(), binary(), binary()} | {event_response_error, integer(), gleam@option:option(binary()), binary(), gleam@option:option(binary())}. -file("src/glopenai/response.gleam", 1739). ?DOC(" Create a new response request with required input.\n"). -spec new_create_response(input_param()) -> create_response(). new_create_response(Input) -> {create_response, none, none, none, Input, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none, none}. -file("src/glopenai/response.gleam", 1771). -spec with_model(create_response(), binary()) -> create_response(). with_model(Request, Model) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), {some, Model}, erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1775). -spec with_instructions(create_response(), binary()) -> create_response(). with_instructions(Request, Instructions) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), {some, Instructions}, erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1782). -spec with_tools(create_response(), list(tool())) -> create_response(). with_tools(Request, Tools) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), {some, Tools}, erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1786). -spec with_temperature(create_response(), float()) -> create_response(). with_temperature(Request, Temperature) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), {some, Temperature}, erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1793). -spec with_max_output_tokens(create_response(), integer()) -> create_response(). with_max_output_tokens(Request, Max_output_tokens) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), {some, Max_output_tokens}, erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1800). -spec with_stream(create_response(), boolean()) -> create_response(). with_stream(Request, Stream) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), {some, Stream}, erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1804). -spec with_store(create_response(), boolean()) -> create_response(). with_store(Request, Store) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), {some, Store}, erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1808). -spec with_metadata(create_response(), gleam@dict:dict(binary(), binary())) -> create_response(). with_metadata(Request, Metadata) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), {some, Metadata}, erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1815). -spec with_previous_response_id(create_response(), binary()) -> create_response(). with_previous_response_id(Request, Previous_response_id) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), {some, Previous_response_id}, erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1822). -spec with_reasoning(create_response(), reasoning()) -> create_response(). with_reasoning(Request, Reasoning) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), {some, Reasoning}, erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1829). -spec with_text(create_response(), response_text_param()) -> create_response(). with_text(Request, Text) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), {some, Text}, erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1836). -spec with_tool_choice(create_response(), tool_choice_param()) -> create_response(). with_tool_choice(Request, Tool_choice) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), {some, Tool_choice}, erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1843). -spec with_truncation(create_response(), truncation()) -> create_response(). with_truncation(Request, Truncation) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), {some, Truncation}}. -file("src/glopenai/response.gleam", 1850). -spec with_service_tier(create_response(), service_tier()) -> create_response(). with_service_tier(Request, Tier) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), {some, Tier}, erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1857). -spec with_top_p(create_response(), float()) -> create_response(). with_top_p(Request, Top_p) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), {some, Top_p}, erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1861). -spec with_include(create_response(), list(include_enum())) -> create_response(). with_include(Request, Include) -> {create_response, erlang:element(2, Request), erlang:element(3, Request), {some, Include}, erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1868). -spec with_conversation(create_response(), conversation_param()) -> create_response(). with_conversation(Request, Conversation) -> {create_response, erlang:element(2, Request), {some, Conversation}, erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1875). -spec with_background(create_response(), boolean()) -> create_response(). with_background(Request, Background) -> {create_response, {some, Background}, erlang:element(3, Request), erlang:element(4, Request), erlang:element(5, Request), erlang:element(6, Request), erlang:element(7, Request), erlang:element(8, Request), erlang:element(9, Request), erlang:element(10, Request), erlang:element(11, Request), erlang:element(12, Request), erlang:element(13, Request), erlang:element(14, Request), erlang:element(15, Request), erlang:element(16, Request), erlang:element(17, Request), erlang:element(18, Request), erlang:element(19, Request), erlang:element(20, Request), erlang:element(21, Request), erlang:element(22, Request), erlang:element(23, Request), erlang:element(24, Request), erlang:element(25, Request), erlang:element(26, Request), erlang:element(27, Request), erlang:element(28, Request)}. -file("src/glopenai/response.gleam", 1886). -spec message_phase_to_json(message_phase()) -> gleam@json:json(). message_phase_to_json(Phase) -> gleam@json:string(case Phase of commentary -> <<"commentary"/utf8>>; final_answer -> <<"final_answer"/utf8>> end). -file("src/glopenai/response.gleam", 1893). -spec tool_search_execution_type_to_json(tool_search_execution_type()) -> gleam@json:json(). tool_search_execution_type_to_json(T) -> gleam@json:string(case T of execution_server -> <<"server"/utf8>>; execution_client -> <<"client"/utf8>> end). -file("src/glopenai/response.gleam", 1902). -spec search_content_type_to_json(search_content_type()) -> gleam@json:json(). search_content_type_to_json(T) -> gleam@json:string(case T of search_text -> <<"text"/utf8>>; search_image -> <<"image"/utf8>> end). -file("src/glopenai/response.gleam", 1909). -spec output_status_to_json(output_status()) -> gleam@json:json(). output_status_to_json(S) -> gleam@json:string(case S of output_in_progress -> <<"in_progress"/utf8>>; output_completed -> <<"completed"/utf8>>; output_incomplete -> <<"incomplete"/utf8>> end). -file("src/glopenai/response.gleam", 1917). -spec role_to_json(role()) -> gleam@json:json(). role_to_json(R) -> gleam@json:string(case R of role_user -> <<"user"/utf8>>; role_assistant -> <<"assistant"/utf8>>; role_system -> <<"system"/utf8>>; role_developer -> <<"developer"/utf8>> end). -file("src/glopenai/response.gleam", 1926). -spec input_role_to_json(input_role()) -> gleam@json:json(). input_role_to_json(R) -> gleam@json:string(case R of input_role_user -> <<"user"/utf8>>; input_role_system -> <<"system"/utf8>>; input_role_developer -> <<"developer"/utf8>> end). -file("src/glopenai/response.gleam", 1934). -spec truncation_to_json(truncation()) -> gleam@json:json(). truncation_to_json(T) -> gleam@json:string(case T of truncation_auto -> <<"auto"/utf8>>; truncation_disabled -> <<"disabled"/utf8>> end). -file("src/glopenai/response.gleam", 1941). -spec service_tier_to_json(service_tier()) -> gleam@json:json(). service_tier_to_json(T) -> gleam@json:string(case T of service_tier_auto -> <<"auto"/utf8>>; service_tier_default -> <<"default"/utf8>>; service_tier_flex -> <<"flex"/utf8>>; service_tier_scale -> <<"scale"/utf8>>; service_tier_priority -> <<"priority"/utf8>> end). -file("src/glopenai/response.gleam", 1951). -spec response_status_to_json(response_status()) -> gleam@json:json(). response_status_to_json(S) -> gleam@json:string(case S of status_completed -> <<"completed"/utf8>>; status_failed -> <<"failed"/utf8>>; status_in_progress -> <<"in_progress"/utf8>>; status_cancelled -> <<"cancelled"/utf8>>; status_queued -> <<"queued"/utf8>>; status_incomplete -> <<"incomplete"/utf8>> end). -file("src/glopenai/response.gleam", 1962). -spec verbosity_to_json(verbosity()) -> gleam@json:json(). verbosity_to_json(V) -> gleam@json:string(case V of verbosity_low -> <<"low"/utf8>>; verbosity_medium -> <<"medium"/utf8>>; verbosity_high -> <<"high"/utf8>> end). -file("src/glopenai/response.gleam", 1970). -spec reasoning_summary_to_json(reasoning_summary()) -> gleam@json:json(). reasoning_summary_to_json(S) -> gleam@json:string(case S of reasoning_summary_auto -> <<"auto"/utf8>>; reasoning_summary_concise -> <<"concise"/utf8>>; reasoning_summary_detailed -> <<"detailed"/utf8>> end). -file("src/glopenai/response.gleam", 1978). -spec prompt_cache_retention_to_json(prompt_cache_retention()) -> gleam@json:json(). prompt_cache_retention_to_json(R) -> gleam@json:string(case R of prompt_cache_in_memory -> <<"in_memory"/utf8>>; prompt_cache_hours24 -> <<"24h"/utf8>> end). -file("src/glopenai/response.gleam", 1985). -spec include_enum_to_json(include_enum()) -> gleam@json:json(). include_enum_to_json(I) -> gleam@json:string(case I of include_file_search_call_results -> <<"file_search_call.results"/utf8>>; include_web_search_call_results -> <<"web_search_call.results"/utf8>>; include_web_search_call_action_sources -> <<"web_search_call.action.sources"/utf8>>; include_message_input_image_image_url -> <<"message.input_image.image_url"/utf8>>; include_computer_call_output_output_image_url -> <<"computer_call_output.output.image_url"/utf8>>; include_code_interpreter_call_outputs -> <<"code_interpreter_call.outputs"/utf8>>; include_reasoning_encrypted_content -> <<"reasoning.encrypted_content"/utf8>>; include_message_output_text_logprobs -> <<"message.output_text.logprobs"/utf8>> end). -file("src/glopenai/response.gleam", 1999). -spec web_search_context_size_to_json(web_search_tool_search_context_size()) -> gleam@json:json(). web_search_context_size_to_json(S) -> gleam@json:string(case S of web_search_context_low -> <<"low"/utf8>>; web_search_context_medium -> <<"medium"/utf8>>; web_search_context_high -> <<"high"/utf8>> end). -file("src/glopenai/response.gleam", 2009). -spec image_gen_bg_to_json(image_gen_tool_background()) -> gleam@json:json(). image_gen_bg_to_json(B) -> gleam@json:string(case B of image_gen_bg_transparent -> <<"transparent"/utf8>>; image_gen_bg_opaque -> <<"opaque"/utf8>>; image_gen_bg_auto -> <<"auto"/utf8>> end). -file("src/glopenai/response.gleam", 2017). -spec image_gen_fmt_to_json(image_gen_tool_output_format()) -> gleam@json:json(). image_gen_fmt_to_json(F) -> gleam@json:string(case F of image_gen_fmt_png -> <<"png"/utf8>>; image_gen_fmt_webp -> <<"webp"/utf8>>; image_gen_fmt_jpeg -> <<"jpeg"/utf8>> end). -file("src/glopenai/response.gleam", 2025). -spec image_gen_quality_to_json(image_gen_tool_quality()) -> gleam@json:json(). image_gen_quality_to_json(Q) -> gleam@json:string(case Q of image_gen_quality_low -> <<"low"/utf8>>; image_gen_quality_medium -> <<"medium"/utf8>>; image_gen_quality_high -> <<"high"/utf8>>; image_gen_quality_auto -> <<"auto"/utf8>> end). -file("src/glopenai/response.gleam", 2034). -spec image_gen_size_to_json(image_gen_tool_size()) -> gleam@json:json(). image_gen_size_to_json(S) -> gleam@json:string(case S of image_gen_size_auto -> <<"auto"/utf8>>; image_gen_size1024x1024 -> <<"1024x1024"/utf8>>; image_gen_size1024x1536 -> <<"1024x1536"/utf8>>; image_gen_size1536x1024 -> <<"1536x1024"/utf8>> end). -file("src/glopenai/response.gleam", 2043). -spec input_fidelity_to_json(input_fidelity()) -> gleam@json:json(). input_fidelity_to_json(F) -> gleam@json:string(case F of fidelity_high -> <<"high"/utf8>>; fidelity_low -> <<"low"/utf8>> end). -file("src/glopenai/response.gleam", 2050). -spec image_gen_moderation_to_json(image_gen_tool_moderation()) -> gleam@json:json(). image_gen_moderation_to_json(M) -> gleam@json:string(case M of image_gen_moderation_auto -> <<"auto"/utf8>>; image_gen_moderation_low -> <<"low"/utf8>> end). -file("src/glopenai/response.gleam", 2057). -spec image_gen_action_to_json(image_gen_action_enum()) -> gleam@json:json(). image_gen_action_to_json(A) -> gleam@json:string(case A of image_gen_generate -> <<"generate"/utf8>>; image_gen_edit -> <<"edit"/utf8>>; image_gen_action_auto -> <<"auto"/utf8>> end). -file("src/glopenai/response.gleam", 2065). -spec tool_choice_options_to_json(tool_choice_options()) -> gleam@json:json(). tool_choice_options_to_json(O) -> gleam@json:string(case O of tool_choice_none -> <<"none"/utf8>>; tool_choice_auto -> <<"auto"/utf8>>; tool_choice_required -> <<"required"/utf8>> end). -file("src/glopenai/response.gleam", 2073). -spec rank_version_type_to_json(rank_version_type()) -> gleam@json:json(). rank_version_type_to_json(R) -> gleam@json:string(case R of rank_auto -> <<"auto"/utf8>>; rank_default20241115 -> <<"default-2024-11-15"/utf8>> end). -file("src/glopenai/response.gleam", 2084). -spec reasoning_to_json(reasoning()) -> gleam@json:json(). reasoning_to_json(R) -> glopenai@internal@codec:object_with_optional( [], [glopenai@internal@codec:optional_field( <<"effort"/utf8>>, erlang:element(2, R), fun glopenai@shared:reasoning_effort_to_json/1 ), glopenai@internal@codec:optional_field( <<"summary"/utf8>>, erlang:element(3, R), fun reasoning_summary_to_json/1 )] ). -file("src/glopenai/response.gleam", 2091). -spec input_content_to_json(input_content()) -> gleam@json:json(). input_content_to_json(Content) -> case Content of {content_input_text, C} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"input_text"/utf8>>)}, {<<"text"/utf8>>, gleam@json:string(erlang:element(2, C))}] ); {content_input_image, C@1} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"input_image"/utf8>>)}, {<<"detail"/utf8>>, glopenai@shared:image_detail_to_json( erlang:element(2, C@1) )}], [glopenai@internal@codec:optional_field( <<"file_id"/utf8>>, erlang:element(3, C@1), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"image_url"/utf8>>, erlang:element(4, C@1), fun gleam@json:string/1 )] ); {content_input_file, C@2} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"input_file"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"file_data"/utf8>>, erlang:element(2, C@2), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"file_id"/utf8>>, erlang:element(3, C@2), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"file_url"/utf8>>, erlang:element(4, C@2), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"filename"/utf8>>, erlang:element(5, C@2), fun gleam@json:string/1 )] ) end. -file("src/glopenai/response.gleam", 2119). -spec easy_input_content_to_json(easy_input_content()) -> gleam@json:json(). easy_input_content_to_json(C) -> case C of {easy_content_text, T} -> gleam@json:string(T); {easy_content_list, Parts} -> gleam@json:array(Parts, fun input_content_to_json/1) end. -file("src/glopenai/response.gleam", 2126). -spec easy_input_message_to_json(easy_input_message()) -> gleam@json:json(). easy_input_message_to_json(M) -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"message"/utf8>>)}, {<<"role"/utf8>>, role_to_json(erlang:element(2, M))}, {<<"content"/utf8>>, easy_input_content_to_json(erlang:element(3, M))}], [glopenai@internal@codec:optional_field( <<"phase"/utf8>>, erlang:element(4, M), fun message_phase_to_json/1 )] ). -file("src/glopenai/response.gleam", 2155). -spec function_tool_to_json(function_tool()) -> gleam@json:json(). function_tool_to_json(Tool) -> glopenai@internal@codec:object_with_optional( [{<<"name"/utf8>>, gleam@json:string(erlang:element(2, Tool))}], [glopenai@internal@codec:optional_field( <<"parameters"/utf8>>, erlang:element(3, Tool), fun glopenai_codec_ffi:dynamic_to_json/1 ), glopenai@internal@codec:optional_field( <<"strict"/utf8>>, erlang:element(4, Tool), fun gleam@json:bool/1 ), glopenai@internal@codec:optional_field( <<"description"/utf8>>, erlang:element(5, Tool), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"defer_loading"/utf8>>, erlang:element(6, Tool), fun gleam@json:bool/1 )] ). -file("src/glopenai/response.gleam", 2164). -spec web_search_tool_to_json(web_search_tool()) -> gleam@json:json(). web_search_tool_to_json(Tool) -> glopenai@internal@codec:object_with_optional( [], [glopenai@internal@codec:optional_field( <<"filters"/utf8>>, erlang:element(2, Tool), fun(F) -> glopenai@internal@codec:object_with_optional( [], [glopenai@internal@codec:optional_field( <<"allowed_domains"/utf8>>, erlang:element(2, F), fun(D) -> gleam@json:array(D, fun gleam@json:string/1) end )] ) end ), glopenai@internal@codec:optional_field( <<"user_location"/utf8>>, erlang:element(3, Tool), fun(Loc) -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"approximate"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"city"/utf8>>, erlang:element(2, Loc), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"country"/utf8>>, erlang:element(3, Loc), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"region"/utf8>>, erlang:element(4, Loc), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"timezone"/utf8>>, erlang:element(5, Loc), fun gleam@json:string/1 )] ) end ), glopenai@internal@codec:optional_field( <<"search_context_size"/utf8>>, erlang:element(4, Tool), fun web_search_context_size_to_json/1 ), glopenai@internal@codec:optional_field( <<"search_content_types"/utf8>>, erlang:element(5, Tool), fun(Types) -> gleam@json:array(Types, fun search_content_type_to_json/1) end )] ). -file("src/glopenai/response.gleam", 2194). -spec image_gen_tool_to_json(image_gen_tool()) -> gleam@json:json(). image_gen_tool_to_json(Tool) -> glopenai@internal@codec:object_with_optional( [], [glopenai@internal@codec:optional_field( <<"background"/utf8>>, erlang:element(2, Tool), fun image_gen_bg_to_json/1 ), glopenai@internal@codec:optional_field( <<"input_fidelity"/utf8>>, erlang:element(3, Tool), fun input_fidelity_to_json/1 ), glopenai@internal@codec:optional_field( <<"input_image_mask"/utf8>>, erlang:element(4, Tool), fun(M) -> glopenai@internal@codec:object_with_optional( [], [glopenai@internal@codec:optional_field( <<"image_url"/utf8>>, erlang:element(2, M), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"file_id"/utf8>>, erlang:element(3, M), fun gleam@json:string/1 )] ) end ), glopenai@internal@codec:optional_field( <<"model"/utf8>>, erlang:element(5, Tool), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"moderation"/utf8>>, erlang:element(6, Tool), fun image_gen_moderation_to_json/1 ), glopenai@internal@codec:optional_field( <<"output_compression"/utf8>>, erlang:element(7, Tool), fun gleam@json:int/1 ), glopenai@internal@codec:optional_field( <<"output_format"/utf8>>, erlang:element(8, Tool), fun image_gen_fmt_to_json/1 ), glopenai@internal@codec:optional_field( <<"partial_images"/utf8>>, erlang:element(9, Tool), fun gleam@json:int/1 ), glopenai@internal@codec:optional_field( <<"quality"/utf8>>, erlang:element(10, Tool), fun image_gen_quality_to_json/1 ), glopenai@internal@codec:optional_field( <<"size"/utf8>>, erlang:element(11, Tool), fun image_gen_size_to_json/1 ), glopenai@internal@codec:optional_field( <<"action"/utf8>>, erlang:element(12, Tool), fun image_gen_action_to_json/1 )] ). -file("src/glopenai/response.gleam", 2380). -spec custom_tool_param_format_to_json(custom_tool_param_format()) -> gleam@json:json(). custom_tool_param_format_to_json(F) -> case F of custom_format_text -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"text"/utf8>>)}] ); {custom_format_grammar, _} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"grammar"/utf8>>)}] ) end. -file("src/glopenai/response.gleam", 2366). -spec custom_tool_param_to_json(custom_tool_param()) -> gleam@json:json(). custom_tool_param_to_json(T) -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"custom"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, T))}, {<<"format"/utf8>>, custom_tool_param_format_to_json(erlang:element(4, T))}], [glopenai@internal@codec:optional_field( <<"description"/utf8>>, erlang:element(3, T), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"defer_loading"/utf8>>, erlang:element(5, T), fun gleam@json:bool/1 )] ). -file("src/glopenai/response.gleam", 2387). -spec namespace_tool_param_tool_to_json(namespace_tool_param_tool()) -> gleam@json:json(). namespace_tool_param_tool_to_json(T) -> case T of {namespace_function, F} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"function"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, F))}], [glopenai@internal@codec:optional_field( <<"description"/utf8>>, erlang:element(3, F), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"parameters"/utf8>>, erlang:element(4, F), fun glopenai_codec_ffi:dynamic_to_json/1 ), glopenai@internal@codec:optional_field( <<"strict"/utf8>>, erlang:element(5, F), fun gleam@json:bool/1 ), glopenai@internal@codec:optional_field( <<"defer_loading"/utf8>>, erlang:element(6, F), fun gleam@json:bool/1 )] ); {namespace_custom, C} -> custom_tool_param_to_json(C) end. -file("src/glopenai/response.gleam", 2410). -spec code_interpreter_container_to_json(code_interpreter_tool_container()) -> gleam@json:json(). code_interpreter_container_to_json(C) -> case C of {code_interp_container_auto, A} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"auto"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"file_ids"/utf8>>, erlang:element(2, A), fun(Ids) -> gleam@json:array(Ids, fun gleam@json:string/1) end ), glopenai@internal@codec:optional_field( <<"memory_limit"/utf8>>, erlang:element(3, A), fun gleam@json:int/1 )] ); {code_interp_container_id, Id} -> gleam@json:string(Id) end. -file("src/glopenai/response.gleam", 2425). -spec function_shell_environment_to_json(function_shell_environment()) -> gleam@json:json(). function_shell_environment_to_json(Env) -> case Env of {function_shell_env_container_auto, A} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"container_auto"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"file_ids"/utf8>>, erlang:element(2, A), fun(Ids) -> gleam@json:array(Ids, fun gleam@json:string/1) end ), glopenai@internal@codec:optional_field( <<"network_policy"/utf8>>, erlang:element(3, A), fun glopenai_codec_ffi:dynamic_to_json/1 ), glopenai@internal@codec:optional_field( <<"skills"/utf8>>, erlang:element(4, A), fun glopenai_codec_ffi:dynamic_to_json/1 )] ); {function_shell_env_local, L} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"local"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"skills"/utf8>>, erlang:element(2, L), fun glopenai_codec_ffi:dynamic_to_json/1 )] ); {function_shell_env_container_reference, R} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"container_reference"/utf8>>)}, {<<"container_id"/utf8>>, gleam@json:string(erlang:element(2, R))}] ) end. -file("src/glopenai/response.gleam", 2453). -spec web_search_tool_with_type(binary(), web_search_tool()) -> gleam@json:json(). web_search_tool_with_type(Type_name, Tool) -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(Type_name)}], [glopenai@internal@codec:optional_field( <<"filters"/utf8>>, erlang:element(2, Tool), fun(F) -> glopenai@internal@codec:object_with_optional( [], [glopenai@internal@codec:optional_field( <<"allowed_domains"/utf8>>, erlang:element(2, F), fun(D) -> gleam@json:array(D, fun gleam@json:string/1) end )] ) end ), glopenai@internal@codec:optional_field( <<"user_location"/utf8>>, erlang:element(3, Tool), fun(Loc) -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"approximate"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"city"/utf8>>, erlang:element(2, Loc), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"country"/utf8>>, erlang:element(3, Loc), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"region"/utf8>>, erlang:element(4, Loc), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"timezone"/utf8>>, erlang:element(5, Loc), fun gleam@json:string/1 )] ) end ), glopenai@internal@codec:optional_field( <<"search_context_size"/utf8>>, erlang:element(4, Tool), fun web_search_context_size_to_json/1 ), glopenai@internal@codec:optional_field( <<"search_content_types"/utf8>>, erlang:element(5, Tool), fun(Types) -> gleam@json:array(Types, fun search_content_type_to_json/1) end )] ). -file("src/glopenai/response.gleam", 2231). -spec tool_to_json(tool()) -> gleam@json:json(). tool_to_json(Tool) -> case Tool of {tool_function, T} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"function"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, T))}], [glopenai@internal@codec:optional_field( <<"parameters"/utf8>>, erlang:element(3, T), fun glopenai_codec_ffi:dynamic_to_json/1 ), glopenai@internal@codec:optional_field( <<"strict"/utf8>>, erlang:element(4, T), fun gleam@json:bool/1 ), glopenai@internal@codec:optional_field( <<"description"/utf8>>, erlang:element(5, T), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"defer_loading"/utf8>>, erlang:element(6, T), fun gleam@json:bool/1 )] ); {tool_file_search, T@1} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"file_search"/utf8>>)}, {<<"vector_store_ids"/utf8>>, gleam@json:array( erlang:element(2, T@1), fun gleam@json:string/1 )}], [glopenai@internal@codec:optional_field( <<"max_num_results"/utf8>>, erlang:element(3, T@1), fun gleam@json:int/1 ), glopenai@internal@codec:optional_field( <<"filters"/utf8>>, erlang:element(4, T@1), fun glopenai_codec_ffi:dynamic_to_json/1 ), glopenai@internal@codec:optional_field( <<"ranking_options"/utf8>>, erlang:element(5, T@1), fun(R) -> glopenai@internal@codec:object_with_optional( [{<<"ranker"/utf8>>, rank_version_type_to_json( erlang:element(3, R) )}], [glopenai@internal@codec:optional_field( <<"hybrid_search"/utf8>>, erlang:element(2, R), fun(H) -> gleam@json:object( [{<<"embedding_weight"/utf8>>, gleam@json:float( erlang:element(2, H) )}, {<<"text_weight"/utf8>>, gleam@json:float( erlang:element(3, H) )}] ) end ), glopenai@internal@codec:optional_field( <<"score_threshold"/utf8>>, erlang:element(4, R), fun gleam@json:float/1 )] ) end )] ); {tool_web_search, T@2} -> web_search_tool_with_type(<<"web_search"/utf8>>, T@2); {tool_web_search20250826, T@3} -> web_search_tool_with_type(<<"web_search_2025_08_26"/utf8>>, T@3); {tool_web_search_preview, T@4} -> web_search_tool_with_type(<<"web_search_preview"/utf8>>, T@4); {tool_web_search_preview20250311, T@5} -> web_search_tool_with_type( <<"web_search_preview_2025_03_11"/utf8>>, T@5 ); {tool_code_interpreter, T@6} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"code_interpreter"/utf8>>)}, {<<"container"/utf8>>, code_interpreter_container_to_json( erlang:element(2, T@6) )}] ); {tool_image_generation, T@7} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"image_generation"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"background"/utf8>>, erlang:element(2, T@7), fun image_gen_bg_to_json/1 ), glopenai@internal@codec:optional_field( <<"input_fidelity"/utf8>>, erlang:element(3, T@7), fun input_fidelity_to_json/1 ), glopenai@internal@codec:optional_field( <<"model"/utf8>>, erlang:element(5, T@7), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"moderation"/utf8>>, erlang:element(6, T@7), fun image_gen_moderation_to_json/1 ), glopenai@internal@codec:optional_field( <<"output_format"/utf8>>, erlang:element(8, T@7), fun image_gen_fmt_to_json/1 ), glopenai@internal@codec:optional_field( <<"quality"/utf8>>, erlang:element(10, T@7), fun image_gen_quality_to_json/1 ), glopenai@internal@codec:optional_field( <<"size"/utf8>>, erlang:element(11, T@7), fun image_gen_size_to_json/1 ), glopenai@internal@codec:optional_field( <<"action"/utf8>>, erlang:element(12, T@7), fun image_gen_action_to_json/1 )] ); tool_local_shell -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"local_shell"/utf8>>)}] ); tool_apply_patch -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"apply_patch"/utf8>>)}] ); tool_computer -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"computer"/utf8>>)}] ); {tool_mcp, _} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"mcp"/utf8>>)}] ); {tool_computer_use_preview, T@8} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"computer_use_preview"/utf8>>)}, {<<"environment"/utf8>>, gleam@json:string(case erlang:element(2, T@8) of environment_windows -> <<"windows"/utf8>>; environment_mac -> <<"mac"/utf8>>; environment_linux -> <<"linux"/utf8>>; environment_ubuntu -> <<"ubuntu"/utf8>>; environment_browser -> <<"browser"/utf8>> end)}, {<<"display_width"/utf8>>, gleam@json:int(erlang:element(3, T@8))}, {<<"display_height"/utf8>>, gleam@json:int(erlang:element(4, T@8))}] ); {tool_shell, T@9} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"shell"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"environment"/utf8>>, erlang:element(2, T@9), fun function_shell_environment_to_json/1 )] ); {tool_custom, T@10} -> custom_tool_param_to_json(T@10); {tool_namespace, T@11} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"namespace"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, T@11))}, {<<"description"/utf8>>, gleam@json:string(erlang:element(3, T@11))}, {<<"tools"/utf8>>, gleam@json:array( erlang:element(4, T@11), fun namespace_tool_param_tool_to_json/1 )}] ); {tool_tool_search, T@12} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"tool_search"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"execution"/utf8>>, erlang:element(2, T@12), fun tool_search_execution_type_to_json/1 ), glopenai@internal@codec:optional_field( <<"description"/utf8>>, erlang:element(3, T@12), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"parameters"/utf8>>, erlang:element(4, T@12), fun glopenai_codec_ffi:dynamic_to_json/1 )] ) end. -file("src/glopenai/response.gleam", 2486). -spec text_response_format_to_json(text_response_format_configuration()) -> gleam@json:json(). text_response_format_to_json(F) -> case F of text_format_text -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"text"/utf8>>)}] ); text_format_json_object -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"json_object"/utf8>>)}] ); {text_format_json_schema, Schema} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"json_schema"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, Schema))}], [glopenai@internal@codec:optional_field( <<"description"/utf8>>, erlang:element(3, Schema), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"schema"/utf8>>, erlang:element(4, Schema), fun glopenai_codec_ffi:dynamic_to_json/1 ), glopenai@internal@codec:optional_field( <<"strict"/utf8>>, erlang:element(5, Schema), fun gleam@json:bool/1 )] ) end. -file("src/glopenai/response.gleam", 2510). -spec response_text_param_to_json(response_text_param()) -> gleam@json:json(). response_text_param_to_json(P) -> glopenai@internal@codec:object_with_optional( [{<<"format"/utf8>>, text_response_format_to_json(erlang:element(2, P))}], [glopenai@internal@codec:optional_field( <<"verbosity"/utf8>>, erlang:element(3, P), fun verbosity_to_json/1 )] ). -file("src/glopenai/response.gleam", 2517). -spec tool_choice_param_to_json(tool_choice_param()) -> gleam@json:json(). tool_choice_param_to_json(Tc) -> case Tc of {tool_choice_param_mode, Mode} -> tool_choice_options_to_json(Mode); {tool_choice_param_function, F} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"function"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, F))}] ); {tool_choice_param_mcp, M} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"mcp"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, M))}, {<<"server_label"/utf8>>, gleam@json:string(erlang:element(3, M))}] ); {tool_choice_param_custom, C} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"custom"/utf8>>)}, {<<"name"/utf8>>, gleam@json:string(erlang:element(2, C))}] ); tool_choice_param_apply_patch -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"apply_patch"/utf8>>)}] ); tool_choice_param_shell -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"shell"/utf8>>)}] ); {tool_choice_param_hosted, H} -> Type_str = case H of tool_choice_file_search -> <<"file_search"/utf8>>; tool_choice_web_search_preview -> <<"web_search_preview"/utf8>>; tool_choice_computer -> <<"computer"/utf8>>; tool_choice_computer_use_preview -> <<"computer_use_preview"/utf8>>; tool_choice_computer_use -> <<"computer_use"/utf8>>; tool_choice_web_search_preview20250311 -> <<"web_search_preview_2025_03_11"/utf8>>; tool_choice_code_interpreter -> <<"code_interpreter"/utf8>>; tool_choice_image_generation -> <<"image_generation"/utf8>> end, gleam@json:object([{<<"type"/utf8>>, gleam@json:string(Type_str)}]); {tool_choice_param_allowed_tools, A} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"allowed_tools"/utf8>>)}, {<<"mode"/utf8>>, gleam@json:string(case erlang:element(2, A) of allowed_mode_auto -> <<"auto"/utf8>>; allowed_mode_required -> <<"required"/utf8>> end)}, {<<"tools"/utf8>>, glopenai_codec_ffi:dynamic_to_json(erlang:element(3, A))}] ) end. -file("src/glopenai/response.gleam", 2567). -spec conversation_param_to_json(conversation_param()) -> gleam@json:json(). conversation_param_to_json(C) -> case C of {conversation_id, Id} -> gleam@json:string(Id); {conversation_object, Conv} -> gleam@json:object( [{<<"id"/utf8>>, gleam@json:string(erlang:element(2, Conv))}] ) end. -file("src/glopenai/response.gleam", 2574). -spec prompt_to_json(prompt()) -> gleam@json:json(). prompt_to_json(P) -> glopenai@internal@codec:object_with_optional( [{<<"id"/utf8>>, gleam@json:string(erlang:element(2, P))}], [glopenai@internal@codec:optional_field( <<"version"/utf8>>, erlang:element(3, P), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"variables"/utf8>>, erlang:element(4, P), fun glopenai_codec_ffi:dynamic_to_json/1 )] ). -file("src/glopenai/response.gleam", 2581). -spec response_stream_options_to_json(response_stream_options()) -> gleam@json:json(). response_stream_options_to_json(O) -> glopenai@internal@codec:object_with_optional( [], [glopenai@internal@codec:optional_field( <<"include_obfuscation"/utf8>>, erlang:element(2, O), fun gleam@json:bool/1 )] ). -file("src/glopenai/response.gleam", 2712). -spec annotation_to_json(annotation()) -> gleam@json:json(). annotation_to_json(A) -> case A of {annotation_file_citation, C} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"file_citation"/utf8>>)}, {<<"file_id"/utf8>>, gleam@json:string(erlang:element(2, C))}, {<<"filename"/utf8>>, gleam@json:string(erlang:element(3, C))}, {<<"index"/utf8>>, gleam@json:int(erlang:element(4, C))}] ); {annotation_url_citation, C@1} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"url_citation"/utf8>>)}, {<<"end_index"/utf8>>, gleam@json:int(erlang:element(2, C@1))}, {<<"start_index"/utf8>>, gleam@json:int(erlang:element(3, C@1))}, {<<"title"/utf8>>, gleam@json:string(erlang:element(4, C@1))}, {<<"url"/utf8>>, gleam@json:string(erlang:element(5, C@1))}] ); {annotation_container_file_citation, C@2} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"container_file_citation"/utf8>>)}, {<<"container_id"/utf8>>, gleam@json:string(erlang:element(2, C@2))}, {<<"end_index"/utf8>>, gleam@json:int(erlang:element(3, C@2))}, {<<"file_id"/utf8>>, gleam@json:string(erlang:element(4, C@2))}, {<<"filename"/utf8>>, gleam@json:string(erlang:element(5, C@2))}, {<<"start_index"/utf8>>, gleam@json:int(erlang:element(6, C@2))}] ); {annotation_file_path, P} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"file_path"/utf8>>)}, {<<"file_id"/utf8>>, gleam@json:string(erlang:element(2, P))}, {<<"index"/utf8>>, gleam@json:int(erlang:element(3, P))}] ) end. -file("src/glopenai/response.gleam", 2696). -spec output_message_content_to_json(output_message_content()) -> gleam@json:json(). output_message_content_to_json(C) -> case C of {output_message_output_text, T} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"output_text"/utf8>>)}, {<<"text"/utf8>>, gleam@json:string(erlang:element(4, T))}, {<<"annotations"/utf8>>, gleam@json:array( erlang:element(2, T), fun annotation_to_json/1 )}] ); {output_message_refusal, R} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"refusal"/utf8>>)}, {<<"refusal"/utf8>>, gleam@json:string(erlang:element(2, R))}] ) end. -file("src/glopenai/response.gleam", 2671). -spec message_item_to_json(message_item()) -> gleam@json:json(). message_item_to_json(M) -> case M of {message_item_output, O} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"message"/utf8>>)}, {<<"role"/utf8>>, gleam@json:string(<<"assistant"/utf8>>)}, {<<"id"/utf8>>, gleam@json:string(erlang:element(3, O))}, {<<"content"/utf8>>, gleam@json:array( erlang:element(2, O), fun output_message_content_to_json/1 )}, {<<"status"/utf8>>, output_status_to_json(erlang:element(6, O))}], [glopenai@internal@codec:optional_field( <<"phase"/utf8>>, erlang:element(5, O), fun message_phase_to_json/1 )] ); {message_item_input, I} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"message"/utf8>>)}, {<<"role"/utf8>>, input_role_to_json(erlang:element(3, I))}, {<<"content"/utf8>>, gleam@json:array( erlang:element(2, I), fun input_content_to_json/1 )}], [glopenai@internal@codec:optional_field( <<"status"/utf8>>, erlang:element(4, I), fun output_status_to_json/1 )] ) end. -file("src/glopenai/response.gleam", 2747). -spec function_call_output_to_json(function_call_output()) -> gleam@json:json(). function_call_output_to_json(O) -> case O of {function_call_output_text, T} -> gleam@json:string(T); {function_call_output_content, Parts} -> gleam@json:array(Parts, fun input_content_to_json/1) end. -file("src/glopenai/response.gleam", 2754). -spec computer_screenshot_image_to_json(computer_screenshot_image()) -> gleam@json:json(). computer_screenshot_image_to_json(Img) -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"computer_screenshot"/utf8>>)}], [glopenai@internal@codec:optional_field( <<"file_id"/utf8>>, erlang:element(2, Img), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"image_url"/utf8>>, erlang:element(3, Img), fun gleam@json:string/1 )] ). -file("src/glopenai/response.gleam", 2761). -spec computer_call_safety_check_to_json(computer_call_safety_check_param()) -> gleam@json:json(). computer_call_safety_check_to_json(Check) -> glopenai@internal@codec:object_with_optional( [{<<"id"/utf8>>, gleam@json:string(erlang:element(2, Check))}], [glopenai@internal@codec:optional_field( <<"code"/utf8>>, erlang:element(3, Check), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"message"/utf8>>, erlang:element(4, Check), fun gleam@json:string/1 )] ). -file("src/glopenai/response.gleam", 2796). -spec summary_part_to_json(summary_part()) -> gleam@json:json(). summary_part_to_json(P) -> case P of {summary_part_summary_text, T} -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"summary_text"/utf8>>)}, {<<"text"/utf8>>, gleam@json:string(erlang:element(2, T))}] ) end. -file("src/glopenai/response.gleam", 2770). -spec reasoning_item_to_json(reasoning_item(), binary()) -> gleam@json:json(). reasoning_item_to_json(R, Type_tag) -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(Type_tag)}, {<<"id"/utf8>>, gleam@json:string(erlang:element(2, R))}, {<<"summary"/utf8>>, gleam@json:array( erlang:element(3, R), fun summary_part_to_json/1 )}], [glopenai@internal@codec:optional_field( <<"content"/utf8>>, erlang:element(4, R), fun(C) -> gleam@json:array( C, fun(T) -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string( <<"reasoning_text"/utf8>> )}, {<<"text"/utf8>>, gleam@json:string(erlang:element(2, T))}] ) end ) end ), glopenai@internal@codec:optional_field( <<"encrypted_content"/utf8>>, erlang:element(5, R), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"status"/utf8>>, erlang:element(6, R), fun output_status_to_json/1 )] ). -file("src/glopenai/response.gleam", 2593). ?DOC( " Encode the item tagged union. Since this has many variants, we encode\n" " just the type tag + the inner struct's fields.\n" ). -spec item_to_json(item()) -> gleam@json:json(). item_to_json(Item) -> case Item of {item_message, M} -> message_item_to_json(M); {item_function_call, F} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"function_call"/utf8>>)}, {<<"arguments"/utf8>>, gleam@json:string(erlang:element(2, F))}, {<<"call_id"/utf8>>, gleam@json:string(erlang:element(3, F))}, {<<"name"/utf8>>, gleam@json:string(erlang:element(5, F))}], [glopenai@internal@codec:optional_field( <<"namespace"/utf8>>, erlang:element(4, F), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"id"/utf8>>, erlang:element(6, F), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"status"/utf8>>, erlang:element(7, F), fun output_status_to_json/1 )] ); {item_function_call_output, F@1} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"function_call_output"/utf8>>)}, {<<"call_id"/utf8>>, gleam@json:string(erlang:element(2, F@1))}, {<<"output"/utf8>>, function_call_output_to_json(erlang:element(3, F@1))}], [glopenai@internal@codec:optional_field( <<"id"/utf8>>, erlang:element(4, F@1), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"status"/utf8>>, erlang:element(5, F@1), fun output_status_to_json/1 )] ); {item_reasoning, R} -> reasoning_item_to_json(R, <<"reasoning"/utf8>>); {item_compaction, C} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"compaction"/utf8>>)}, {<<"encrypted_content"/utf8>>, gleam@json:string(erlang:element(3, C))}], [glopenai@internal@codec:optional_field( <<"id"/utf8>>, erlang:element(2, C), fun gleam@json:string/1 )] ); {item_mcp_approval_response, R@1} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"mcp_approval_response"/utf8>>)}, {<<"approval_request_id"/utf8>>, gleam@json:string(erlang:element(2, R@1))}, {<<"approve"/utf8>>, gleam@json:bool(erlang:element(3, R@1))}], [glopenai@internal@codec:optional_field( <<"id"/utf8>>, erlang:element(4, R@1), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"reason"/utf8>>, erlang:element(5, R@1), fun gleam@json:string/1 )] ); {item_computer_call_output, C@1} -> glopenai@internal@codec:object_with_optional( [{<<"type"/utf8>>, gleam@json:string(<<"computer_call_output"/utf8>>)}, {<<"call_id"/utf8>>, gleam@json:string(erlang:element(2, C@1))}, {<<"output"/utf8>>, computer_screenshot_image_to_json( erlang:element(3, C@1) )}], [glopenai@internal@codec:optional_field( <<"acknowledged_safety_checks"/utf8>>, erlang:element(4, C@1), fun(Checks) -> gleam@json:array( Checks, fun computer_call_safety_check_to_json/1 ) end ), glopenai@internal@codec:optional_field( <<"id"/utf8>>, erlang:element(5, C@1), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"status"/utf8>>, erlang:element(6, C@1), fun output_status_to_json/1 )] ); _ -> gleam@json:object( [{<<"type"/utf8>>, gleam@json:string(<<"unknown"/utf8>>)}] ) end. -file("src/glopenai/response.gleam", 2144). -spec input_item_to_json(input_item()) -> gleam@json:json(). input_item_to_json(Item) -> case Item of {input_item_reference, Ref} -> glopenai@internal@codec:object_with_optional( [{<<"id"/utf8>>, gleam@json:string(erlang:element(3, Ref))}], [glopenai@internal@codec:optional_field( <<"type"/utf8>>, erlang:element(2, Ref), fun gleam@json:string/1 )] ); {input_item_item, I} -> item_to_json(I); {input_item_easy_message, M} -> easy_input_message_to_json(M) end. -file("src/glopenai/response.gleam", 2137). -spec input_param_to_json(input_param()) -> gleam@json:json(). input_param_to_json(Input) -> case Input of {input_text, T} -> gleam@json:string(T); {input_items, Items} -> gleam@json:array(Items, fun input_item_to_json/1) end. -file("src/glopenai/response.gleam", 2810). -spec create_response_to_json(create_response()) -> gleam@json:json(). create_response_to_json(Request) -> glopenai@internal@codec:object_with_optional( [{<<"input"/utf8>>, input_param_to_json(erlang:element(5, Request))}], [glopenai@internal@codec:optional_field( <<"background"/utf8>>, erlang:element(2, Request), fun gleam@json:bool/1 ), glopenai@internal@codec:optional_field( <<"conversation"/utf8>>, erlang:element(3, Request), fun conversation_param_to_json/1 ), glopenai@internal@codec:optional_field( <<"include"/utf8>>, erlang:element(4, Request), fun(I) -> gleam@json:array(I, fun include_enum_to_json/1) end ), glopenai@internal@codec:optional_field( <<"instructions"/utf8>>, erlang:element(6, Request), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"max_output_tokens"/utf8>>, erlang:element(7, Request), fun gleam@json:int/1 ), glopenai@internal@codec:optional_field( <<"max_tool_calls"/utf8>>, erlang:element(8, Request), fun gleam@json:int/1 ), glopenai@internal@codec:optional_field( <<"metadata"/utf8>>, erlang:element(9, Request), fun(M) -> gleam@json:object( begin _pipe = maps:to_list(M), gleam@list:map( _pipe, fun(Pair) -> {erlang:element(1, Pair), gleam@json:string( erlang:element(2, Pair) )} end ) end ) end ), glopenai@internal@codec:optional_field( <<"model"/utf8>>, erlang:element(10, Request), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"parallel_tool_calls"/utf8>>, erlang:element(11, Request), fun gleam@json:bool/1 ), glopenai@internal@codec:optional_field( <<"previous_response_id"/utf8>>, erlang:element(12, Request), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"prompt"/utf8>>, erlang:element(13, Request), fun prompt_to_json/1 ), glopenai@internal@codec:optional_field( <<"prompt_cache_key"/utf8>>, erlang:element(14, Request), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"prompt_cache_retention"/utf8>>, erlang:element(15, Request), fun prompt_cache_retention_to_json/1 ), glopenai@internal@codec:optional_field( <<"reasoning"/utf8>>, erlang:element(16, Request), fun reasoning_to_json/1 ), glopenai@internal@codec:optional_field( <<"safety_identifier"/utf8>>, erlang:element(17, Request), fun gleam@json:string/1 ), glopenai@internal@codec:optional_field( <<"service_tier"/utf8>>, erlang:element(18, Request), fun service_tier_to_json/1 ), glopenai@internal@codec:optional_field( <<"store"/utf8>>, erlang:element(19, Request), fun gleam@json:bool/1 ), glopenai@internal@codec:optional_field( <<"stream"/utf8>>, erlang:element(20, Request), fun gleam@json:bool/1 ), glopenai@internal@codec:optional_field( <<"stream_options"/utf8>>, erlang:element(21, Request), fun response_stream_options_to_json/1 ), glopenai@internal@codec:optional_field( <<"temperature"/utf8>>, erlang:element(22, Request), fun gleam@json:float/1 ), glopenai@internal@codec:optional_field( <<"text"/utf8>>, erlang:element(23, Request), fun response_text_param_to_json/1 ), glopenai@internal@codec:optional_field( <<"tool_choice"/utf8>>, erlang:element(24, Request), fun tool_choice_param_to_json/1 ), glopenai@internal@codec:optional_field( <<"tools"/utf8>>, erlang:element(25, Request), fun(T) -> gleam@json:array(T, fun tool_to_json/1) end ), glopenai@internal@codec:optional_field( <<"top_logprobs"/utf8>>, erlang:element(26, Request), fun gleam@json:int/1 ), glopenai@internal@codec:optional_field( <<"top_p"/utf8>>, erlang:element(27, Request), fun gleam@json:float/1 ), glopenai@internal@codec:optional_field( <<"truncation"/utf8>>, erlang:element(28, Request), fun truncation_to_json/1 )] ). -file("src/glopenai/response.gleam", 2894). -spec message_phase_decoder() -> gleam@dynamic@decode:decoder(message_phase()). message_phase_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"commentary"/utf8>> -> gleam@dynamic@decode:success(commentary); <<"final_answer"/utf8>> -> gleam@dynamic@decode:success(final_answer); _ -> gleam@dynamic@decode:failure( commentary, <<"MessagePhase"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2903). -spec output_status_decoder() -> gleam@dynamic@decode:decoder(output_status()). output_status_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success(output_in_progress); <<"completed"/utf8>> -> gleam@dynamic@decode:success(output_completed); <<"incomplete"/utf8>> -> gleam@dynamic@decode:success(output_incomplete); _ -> gleam@dynamic@decode:failure( output_in_progress, <<"OutputStatus"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2913). -spec role_decoder() -> gleam@dynamic@decode:decoder(role()). role_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"user"/utf8>> -> gleam@dynamic@decode:success(role_user); <<"assistant"/utf8>> -> gleam@dynamic@decode:success(role_assistant); <<"system"/utf8>> -> gleam@dynamic@decode:success(role_system); <<"developer"/utf8>> -> gleam@dynamic@decode:success(role_developer); _ -> gleam@dynamic@decode:failure(role_user, <<"Role"/utf8>>) end end ). -file("src/glopenai/response.gleam", 2924). -spec input_role_decoder() -> gleam@dynamic@decode:decoder(input_role()). input_role_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"user"/utf8>> -> gleam@dynamic@decode:success(input_role_user); <<"system"/utf8>> -> gleam@dynamic@decode:success(input_role_system); <<"developer"/utf8>> -> gleam@dynamic@decode:success(input_role_developer); _ -> gleam@dynamic@decode:failure( input_role_user, <<"InputRole"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2934). -spec service_tier_decoder() -> gleam@dynamic@decode:decoder(service_tier()). service_tier_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"auto"/utf8>> -> gleam@dynamic@decode:success(service_tier_auto); <<"default"/utf8>> -> gleam@dynamic@decode:success(service_tier_default); <<"flex"/utf8>> -> gleam@dynamic@decode:success(service_tier_flex); <<"scale"/utf8>> -> gleam@dynamic@decode:success(service_tier_scale); <<"priority"/utf8>> -> gleam@dynamic@decode:success(service_tier_priority); _ -> gleam@dynamic@decode:failure( service_tier_auto, <<"ServiceTier"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2946). -spec response_status_decoder() -> gleam@dynamic@decode:decoder(response_status()). response_status_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"completed"/utf8>> -> gleam@dynamic@decode:success(status_completed); <<"failed"/utf8>> -> gleam@dynamic@decode:success(status_failed); <<"in_progress"/utf8>> -> gleam@dynamic@decode:success(status_in_progress); <<"cancelled"/utf8>> -> gleam@dynamic@decode:success(status_cancelled); <<"queued"/utf8>> -> gleam@dynamic@decode:success(status_queued); <<"incomplete"/utf8>> -> gleam@dynamic@decode:success(status_incomplete); _ -> gleam@dynamic@decode:failure( status_completed, <<"ResponseStatus"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2959). -spec truncation_decoder() -> gleam@dynamic@decode:decoder(truncation()). truncation_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"auto"/utf8>> -> gleam@dynamic@decode:success(truncation_auto); <<"disabled"/utf8>> -> gleam@dynamic@decode:success(truncation_disabled); _ -> gleam@dynamic@decode:failure( truncation_auto, <<"Truncation"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2968). -spec verbosity_decoder() -> gleam@dynamic@decode:decoder(verbosity()). verbosity_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"low"/utf8>> -> gleam@dynamic@decode:success(verbosity_low); <<"medium"/utf8>> -> gleam@dynamic@decode:success(verbosity_medium); <<"high"/utf8>> -> gleam@dynamic@decode:success(verbosity_high); _ -> gleam@dynamic@decode:failure( verbosity_medium, <<"Verbosity"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2978). -spec reasoning_summary_decoder() -> gleam@dynamic@decode:decoder(reasoning_summary()). reasoning_summary_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"auto"/utf8>> -> gleam@dynamic@decode:success(reasoning_summary_auto); <<"concise"/utf8>> -> gleam@dynamic@decode:success(reasoning_summary_concise); <<"detailed"/utf8>> -> gleam@dynamic@decode:success(reasoning_summary_detailed); _ -> gleam@dynamic@decode:failure( reasoning_summary_auto, <<"ReasoningSummary"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 2988). -spec prompt_cache_retention_decoder() -> gleam@dynamic@decode:decoder(prompt_cache_retention()). prompt_cache_retention_decoder() -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"in_memory"/utf8>> -> gleam@dynamic@decode:success(prompt_cache_in_memory); <<"24h"/utf8>> -> gleam@dynamic@decode:success(prompt_cache_hours24); _ -> gleam@dynamic@decode:failure( prompt_cache_in_memory, <<"PromptCacheRetention"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 3001). -spec reasoning_decoder() -> gleam@dynamic@decode:decoder(reasoning()). reasoning_decoder() -> gleam@dynamic@decode:optional_field( <<"effort"/utf8>>, none, gleam@dynamic@decode:optional( glopenai@shared:reasoning_effort_decoder() ), fun(Effort) -> gleam@dynamic@decode:optional_field( <<"summary"/utf8>>, none, gleam@dynamic@decode:optional(reasoning_summary_decoder()), fun(Summary) -> gleam@dynamic@decode:success({reasoning, Effort, Summary}) end ) end ). -file("src/glopenai/response.gleam", 3015). -spec text_response_format_decoder() -> gleam@dynamic@decode:decoder(text_response_format_configuration()). text_response_format_decoder() -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Tag) -> case Tag of <<"text"/utf8>> -> gleam@dynamic@decode:success(text_format_text); <<"json_object"/utf8>> -> gleam@dynamic@decode:success(text_format_json_object); <<"json_schema"/utf8>> -> gleam@dynamic@decode:field( <<"name"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Name) -> gleam@dynamic@decode:optional_field( <<"description"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Description) -> gleam@dynamic@decode:optional_field( <<"schema"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_dynamic/1} ), fun(Schema) -> gleam@dynamic@decode:optional_field( <<"strict"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_bool/1} ), fun(Strict) -> gleam@dynamic@decode:success( {text_format_json_schema, {response_format_json_schema, Name, Description, Schema, Strict}} ) end ) end ) end ) end ); _ -> gleam@dynamic@decode:failure( text_format_text, <<"TextResponseFormatConfiguration"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 3053). -spec response_text_param_decoder() -> gleam@dynamic@decode:decoder(response_text_param()). response_text_param_decoder() -> gleam@dynamic@decode:field( <<"format"/utf8>>, text_response_format_decoder(), fun(Format) -> gleam@dynamic@decode:optional_field( <<"verbosity"/utf8>>, none, gleam@dynamic@decode:optional(verbosity_decoder()), fun(Verbosity) -> gleam@dynamic@decode:success( {response_text_param, Format, Verbosity} ) end ) end ). -file("src/glopenai/response.gleam", 3063). -spec annotation_decoder() -> gleam@dynamic@decode:decoder(annotation()). annotation_decoder() -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Tag) -> case Tag of <<"file_citation"/utf8>> -> gleam@dynamic@decode:field( <<"file_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(File_id) -> gleam@dynamic@decode:field( <<"filename"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Filename) -> gleam@dynamic@decode:field( <<"index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Index) -> gleam@dynamic@decode:success( {annotation_file_citation, {file_citation_body, File_id, Filename, Index}} ) end ) end ) end ); <<"url_citation"/utf8>> -> gleam@dynamic@decode:field( <<"end_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(End_index) -> gleam@dynamic@decode:field( <<"start_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Start_index) -> gleam@dynamic@decode:field( <<"title"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Title) -> gleam@dynamic@decode:field( <<"url"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Url) -> gleam@dynamic@decode:success( {annotation_url_citation, {url_citation_body, End_index, Start_index, Title, Url}} ) end ) end ) end ) end ); <<"container_file_citation"/utf8>> -> gleam@dynamic@decode:field( <<"container_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Container_id) -> gleam@dynamic@decode:field( <<"end_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(End_index@1) -> gleam@dynamic@decode:field( <<"file_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(File_id@1) -> gleam@dynamic@decode:field( <<"filename"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Filename@1) -> gleam@dynamic@decode:field( <<"start_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Start_index@1) -> gleam@dynamic@decode:success( {annotation_container_file_citation, {container_file_citation_body, Container_id, End_index@1, File_id@1, Filename@1, Start_index@1}} ) end ) end ) end ) end ) end ); <<"file_path"/utf8>> -> gleam@dynamic@decode:field( <<"file_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(File_id@2) -> gleam@dynamic@decode:field( <<"index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Index@1) -> gleam@dynamic@decode:success( {annotation_file_path, {file_path_annotation, File_id@2, Index@1}} ) end ) end ); _ -> gleam@dynamic@decode:failure( {annotation_file_path, {file_path_annotation, <<""/utf8>>, 0}}, <<"Annotation"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 3123). -spec response_log_prob_decoder() -> gleam@dynamic@decode:decoder(response_log_prob()). response_log_prob_decoder() -> gleam@dynamic@decode:field( <<"logprob"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_float/1}, fun(Logprob) -> gleam@dynamic@decode:field( <<"token"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Token) -> gleam@dynamic@decode:field( <<"top_logprobs"/utf8>>, gleam@dynamic@decode:list( begin gleam@dynamic@decode:field( <<"logprob"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_float/1}, fun(Lp) -> gleam@dynamic@decode:field( <<"token"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(T) -> gleam@dynamic@decode:success( {response_top_log_prob, Lp, T} ) end ) end ) end ), fun(Top_logprobs) -> gleam@dynamic@decode:success( {response_log_prob, Logprob, Token, Top_logprobs} ) end ) end ) end ). -file("src/glopenai/response.gleam", 3141). -spec output_text_content_decoder() -> gleam@dynamic@decode:decoder(output_text_content()). output_text_content_decoder() -> gleam@dynamic@decode:field( <<"annotations"/utf8>>, gleam@dynamic@decode:list(annotation_decoder()), fun(Annotations) -> gleam@dynamic@decode:optional_field( <<"logprobs"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:list(response_log_prob_decoder()) ), fun(Logprobs) -> gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Text) -> gleam@dynamic@decode:success( {output_text_content, Annotations, Logprobs, Text} ) end ) end ) end ). -file("src/glopenai/response.gleam", 3159). -spec output_message_content_decoder() -> gleam@dynamic@decode:decoder(output_message_content()). output_message_content_decoder() -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Tag) -> case Tag of <<"output_text"/utf8>> -> gleam@dynamic@decode:then( output_text_content_decoder(), fun(Content) -> gleam@dynamic@decode:success( {output_message_output_text, Content} ) end ); <<"refusal"/utf8>> -> gleam@dynamic@decode:field( <<"refusal"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Refusal) -> gleam@dynamic@decode:success( {output_message_refusal, {refusal_content, Refusal}} ) end ); _ -> gleam@dynamic@decode:failure( {output_message_refusal, {refusal_content, <<""/utf8>>}}, <<"OutputMessageContent"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 3178). -spec output_content_decoder() -> gleam@dynamic@decode:decoder(output_content()). output_content_decoder() -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Tag) -> case Tag of <<"output_text"/utf8>> -> gleam@dynamic@decode:then( output_text_content_decoder(), fun(Content) -> gleam@dynamic@decode:success( {output_content_output_text, Content} ) end ); <<"refusal"/utf8>> -> gleam@dynamic@decode:field( <<"refusal"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Refusal) -> gleam@dynamic@decode:success( {output_content_refusal, {refusal_content, Refusal}} ) end ); <<"reasoning_text"/utf8>> -> gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Text) -> gleam@dynamic@decode:success( {output_content_reasoning_text, {reasoning_text_content, Text}} ) end ); _ -> gleam@dynamic@decode:failure( {output_content_refusal, {refusal_content, <<""/utf8>>}}, <<"OutputContent"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 3203). -spec summary_part_decoder() -> gleam@dynamic@decode:decoder(summary_part()). summary_part_decoder() -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(_) -> gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Text) -> gleam@dynamic@decode:success( {summary_part_summary_text, {summary_text_content, Text}} ) end ) end ). -file("src/glopenai/response.gleam", 3209). -spec output_message_decoder() -> gleam@dynamic@decode:decoder(output_message()). output_message_decoder() -> gleam@dynamic@decode:field( <<"content"/utf8>>, gleam@dynamic@decode:list(output_message_content_decoder()), fun(Content) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"role"/utf8>>, role_decoder(), fun(Role) -> gleam@dynamic@decode:optional_field( <<"phase"/utf8>>, none, gleam@dynamic@decode:optional( message_phase_decoder() ), fun(Phase) -> gleam@dynamic@decode:field( <<"status"/utf8>>, output_status_decoder(), fun(Status) -> gleam@dynamic@decode:success( {output_message, Content, Id, Role, Phase, Status} ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 3231). -spec reasoning_item_decoder() -> gleam@dynamic@decode:decoder(reasoning_item()). reasoning_item_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"summary"/utf8>>, gleam@dynamic@decode:list(summary_part_decoder()), fun(Summary) -> gleam@dynamic@decode:optional_field( <<"content"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:list( begin gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Text) -> gleam@dynamic@decode:success( {reasoning_text_content, Text} ) end ) end ) ), fun(Content) -> gleam@dynamic@decode:optional_field( <<"encrypted_content"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Encrypted_content) -> gleam@dynamic@decode:optional_field( <<"status"/utf8>>, none, gleam@dynamic@decode:optional( output_status_decoder() ), fun(Status) -> gleam@dynamic@decode:success( {reasoning_item, Id, Summary, Content, Encrypted_content, Status} ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 3263). -spec function_tool_call_decoder() -> gleam@dynamic@decode:decoder(function_tool_call()). function_tool_call_decoder() -> gleam@dynamic@decode:field( <<"arguments"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Arguments) -> gleam@dynamic@decode:field( <<"call_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Call_id) -> gleam@dynamic@decode:optional_field( <<"namespace"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Namespace) -> gleam@dynamic@decode:field( <<"name"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Name) -> gleam@dynamic@decode:optional_field( <<"id"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Id) -> gleam@dynamic@decode:optional_field( <<"status"/utf8>>, none, gleam@dynamic@decode:optional( output_status_decoder() ), fun(Status) -> gleam@dynamic@decode:success( {function_tool_call, Arguments, Call_id, Namespace, Name, Id, Status} ) end ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 3288). -spec image_gen_tool_call_decoder() -> gleam@dynamic@decode:decoder(image_gen_tool_call()). image_gen_tool_call_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:optional_field( <<"result"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Result) -> gleam@dynamic@decode:field( <<"status"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success( image_gen_call_in_progress ); <<"completed"/utf8>> -> gleam@dynamic@decode:success( image_gen_call_completed ); <<"generating"/utf8>> -> gleam@dynamic@decode:success( image_gen_call_generating ); <<"failed"/utf8>> -> gleam@dynamic@decode:success( image_gen_call_failed ); _ -> gleam@dynamic@decode:failure( image_gen_call_in_progress, <<"ImageGenToolCallStatus"/utf8>> ) end end ) end, fun(Status) -> gleam@dynamic@decode:success( {image_gen_tool_call, Id, Result, Status} ) end ) end ) end ). -file("src/glopenai/response.gleam", 3308). -spec web_search_tool_call_decoder() -> gleam@dynamic@decode:decoder(web_search_tool_call()). web_search_tool_call_decoder() -> gleam@dynamic@decode:field( <<"action"/utf8>>, begin gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Tag) -> case Tag of <<"search"/utf8>> -> gleam@dynamic@decode:field( <<"query"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Query) -> gleam@dynamic@decode:optional_field( <<"sources"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:list( begin gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Source_type) -> gleam@dynamic@decode:field( <<"url"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Url) -> gleam@dynamic@decode:success( {web_search_action_search_source, Source_type, Url} ) end ) end ) end ) ), fun(Sources) -> gleam@dynamic@decode:success( {web_search_action_search_variant, {web_search_action_search, Query, Sources}} ) end ) end ); <<"open_page"/utf8>> -> gleam@dynamic@decode:optional_field( <<"url"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Url@1) -> gleam@dynamic@decode:success( {web_search_action_open_page_variant, {web_search_action_open_page, Url@1}} ) end ); <<"find"/utf8>> -> gleam@dynamic@decode:field( <<"url"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Url@2) -> gleam@dynamic@decode:field( <<"pattern"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Pattern) -> gleam@dynamic@decode:success( {web_search_action_find_variant, {web_search_action_find, Url@2, Pattern}} ) end ) end ); <<"find_in_page"/utf8>> -> gleam@dynamic@decode:field( <<"url"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Url@3) -> gleam@dynamic@decode:field( <<"pattern"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Pattern@1) -> gleam@dynamic@decode:success( {web_search_action_find_in_page_variant, {web_search_action_find, Url@3, Pattern@1}} ) end ) end ); _ -> gleam@dynamic@decode:failure( {web_search_action_search_variant, {web_search_action_search, <<""/utf8>>, none}}, <<"WebSearchToolCallAction"/utf8>> ) end end ) end, fun(Action) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"status"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success( web_search_in_progress ); <<"searching"/utf8>> -> gleam@dynamic@decode:success( web_search_searching ); <<"completed"/utf8>> -> gleam@dynamic@decode:success( web_search_completed ); <<"failed"/utf8>> -> gleam@dynamic@decode:success( web_search_failed ); _ -> gleam@dynamic@decode:failure( web_search_in_progress, <<"WebSearchToolCallStatus"/utf8>> ) end end ) end, fun(Status) -> gleam@dynamic@decode:success( {web_search_tool_call, Action, Id, Status} ) end ) end ) end ). -file("src/glopenai/response.gleam", 3389). -spec file_search_tool_call_decoder() -> gleam@dynamic@decode:decoder(file_search_tool_call()). file_search_tool_call_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"queries"/utf8>>, gleam@dynamic@decode:list( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Queries) -> gleam@dynamic@decode:field( <<"status"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success( file_search_in_progress ); <<"searching"/utf8>> -> gleam@dynamic@decode:success( file_search_searching ); <<"incomplete"/utf8>> -> gleam@dynamic@decode:success( file_search_incomplete ); <<"failed"/utf8>> -> gleam@dynamic@decode:success( file_search_failed ); <<"completed"/utf8>> -> gleam@dynamic@decode:success( file_search_completed ); _ -> gleam@dynamic@decode:failure( file_search_in_progress, <<"FileSearchToolCallStatus"/utf8>> ) end end ) end, fun(Status) -> gleam@dynamic@decode:optional_field( <<"results"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:list( begin gleam@dynamic@decode:field( <<"attributes"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Attributes) -> gleam@dynamic@decode:field( <<"file_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(File_id) -> gleam@dynamic@decode:field( <<"filename"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Filename) -> gleam@dynamic@decode:field( <<"score"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_float/1}, fun( Score ) -> gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Text ) -> gleam@dynamic@decode:success( {file_search_tool_call_result, Attributes, File_id, Filename, Score, Text} ) end ) end ) end ) end ) end ) end ) ), fun(Results) -> gleam@dynamic@decode:success( {file_search_tool_call, Id, Queries, Status, Results} ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 3431). -spec compaction_body_decoder() -> gleam@dynamic@decode:decoder(compaction_body()). compaction_body_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"encrypted_content"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Encrypted_content) -> gleam@dynamic@decode:optional_field( <<"created_by"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Created_by) -> gleam@dynamic@decode:success( {compaction_body, Id, Encrypted_content, Created_by} ) end ) end ) end ). -file("src/glopenai/response.gleam", 3446). -spec mcp_tool_call_decoder() -> gleam@dynamic@decode:decoder(mcp_tool_call()). mcp_tool_call_decoder() -> gleam@dynamic@decode:field( <<"arguments"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Arguments) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"name"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Name) -> gleam@dynamic@decode:field( <<"server_label"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Server_label) -> gleam@dynamic@decode:optional_field( <<"approval_request_id"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Approval_request_id) -> gleam@dynamic@decode:optional_field( <<"error"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Error) -> gleam@dynamic@decode:optional_field( <<"output"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Output) -> gleam@dynamic@decode:optional_field( <<"status"/utf8>>, none, gleam@dynamic@decode:optional( begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Value ) -> case Value of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success( mcp_call_in_progress ); <<"completed"/utf8>> -> gleam@dynamic@decode:success( mcp_call_completed ); <<"incomplete"/utf8>> -> gleam@dynamic@decode:success( mcp_call_incomplete ); <<"calling"/utf8>> -> gleam@dynamic@decode:success( mcp_call_calling ); <<"failed"/utf8>> -> gleam@dynamic@decode:success( mcp_call_failed ); _ -> gleam@dynamic@decode:failure( mcp_call_in_progress, <<"McpToolCallStatus"/utf8>> ) end end ) end ), fun(Status) -> gleam@dynamic@decode:success( {mcp_tool_call, Arguments, Id, Name, Server_label, Approval_request_id, Error, Output, Status} ) end ) end ) end ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 3493). -spec custom_tool_call_decoder() -> gleam@dynamic@decode:decoder(custom_tool_call()). custom_tool_call_decoder() -> gleam@dynamic@decode:field( <<"call_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Call_id) -> gleam@dynamic@decode:optional_field( <<"namespace"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Namespace) -> gleam@dynamic@decode:field( <<"input"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Input) -> gleam@dynamic@decode:field( <<"name"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Name) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:success( {custom_tool_call, Call_id, Namespace, Input, Name, Id} ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 3516). -spec output_item_decoder() -> gleam@dynamic@decode:decoder(output_item()). output_item_decoder() -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Tag) -> case Tag of <<"message"/utf8>> -> gleam@dynamic@decode:then( output_message_decoder(), fun(Msg) -> gleam@dynamic@decode:success( {output_item_message, Msg} ) end ); <<"file_search_call"/utf8>> -> gleam@dynamic@decode:then( file_search_tool_call_decoder(), fun(Call) -> gleam@dynamic@decode:success( {output_item_file_search_call, Call} ) end ); <<"function_call"/utf8>> -> gleam@dynamic@decode:then( function_tool_call_decoder(), fun(Call@1) -> gleam@dynamic@decode:success( {output_item_function_call, Call@1} ) end ); <<"web_search_call"/utf8>> -> gleam@dynamic@decode:then( web_search_tool_call_decoder(), fun(Call@2) -> gleam@dynamic@decode:success( {output_item_web_search_call, Call@2} ) end ); <<"reasoning"/utf8>> -> gleam@dynamic@decode:then( reasoning_item_decoder(), fun(Item) -> gleam@dynamic@decode:success( {output_item_reasoning, Item} ) end ); <<"compaction"/utf8>> -> gleam@dynamic@decode:then( compaction_body_decoder(), fun(Item@1) -> gleam@dynamic@decode:success( {output_item_compaction, Item@1} ) end ); <<"image_generation_call"/utf8>> -> gleam@dynamic@decode:then( image_gen_tool_call_decoder(), fun(Call@3) -> gleam@dynamic@decode:success( {output_item_image_generation_call, Call@3} ) end ); <<"mcp_call"/utf8>> -> gleam@dynamic@decode:then( mcp_tool_call_decoder(), fun(Call@4) -> gleam@dynamic@decode:success( {output_item_mcp_call, Call@4} ) end ); <<"custom_tool_call"/utf8>> -> gleam@dynamic@decode:then( custom_tool_call_decoder(), fun(Call@5) -> gleam@dynamic@decode:success( {output_item_custom_tool_call, Call@5} ) end ); <<"computer_call"/utf8>> -> gleam@dynamic@decode:field( <<"call_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Call_id) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"status"/utf8>>, output_status_decoder(), fun(Status) -> gleam@dynamic@decode:field( <<"pending_safety_checks"/utf8>>, gleam@dynamic@decode:list( begin gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Check_id) -> gleam@dynamic@decode:optional_field( <<"code"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Code) -> gleam@dynamic@decode:optional_field( <<"message"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Message ) -> gleam@dynamic@decode:success( {computer_call_safety_check_param, Check_id, Code, Message} ) end ) end ) end ) end ), fun(Pending_safety_checks) -> gleam@dynamic@decode:optional_field( <<"action"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_dynamic/1} ), fun(_) -> gleam@dynamic@decode:optional_field( <<"actions"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_dynamic/1} ), fun(_) -> gleam@dynamic@decode:success( {output_item_computer_call, {computer_tool_call, none, none, Call_id, Id, Pending_safety_checks, Status}} ) end ) end ) end ) end ) end ) end ); <<"code_interpreter_call"/utf8>> -> gleam@dynamic@decode:optional_field( <<"code"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Code@1) -> gleam@dynamic@decode:field( <<"container_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Container_id) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id@1) -> gleam@dynamic@decode:field( <<"status"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value) -> case Value of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success( code_interp_in_progress ); <<"completed"/utf8>> -> gleam@dynamic@decode:success( code_interp_completed ); <<"incomplete"/utf8>> -> gleam@dynamic@decode:success( code_interp_incomplete ); <<"interpreting"/utf8>> -> gleam@dynamic@decode:success( code_interp_interpreting ); <<"failed"/utf8>> -> gleam@dynamic@decode:success( code_interp_failed ); _ -> gleam@dynamic@decode:failure( code_interp_in_progress, <<"CodeInterpreterToolCallStatus"/utf8>> ) end end ) end, fun(Status@1) -> gleam@dynamic@decode:optional_field( <<"outputs"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:list( begin gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Out_tag ) -> case Out_tag of <<"logs"/utf8>> -> gleam@dynamic@decode:field( <<"logs"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Logs ) -> gleam@dynamic@decode:success( {code_interp_output_logs, {code_interpreter_output_logs, Logs}} ) end ); <<"image"/utf8>> -> gleam@dynamic@decode:field( <<"url"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Url ) -> gleam@dynamic@decode:success( {code_interp_output_image, {code_interpreter_output_image, Url}} ) end ); _ -> gleam@dynamic@decode:failure( {code_interp_output_logs, {code_interpreter_output_logs, <<""/utf8>>}}, <<"CodeInterpreterToolCallOutput"/utf8>> ) end end ) end ) ), fun(Outputs) -> gleam@dynamic@decode:success( {output_item_code_interpreter_call, {code_interpreter_tool_call, Code@1, Container_id, Id@1, Outputs, Status@1}} ) end ) end ) end ) end ) end ); <<"local_shell_call"/utf8>> -> gleam@dynamic@decode:field( <<"call_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Call_id@1) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id@2) -> gleam@dynamic@decode:field( <<"status"/utf8>>, output_status_decoder(), fun(Status@2) -> gleam@dynamic@decode:field( <<"action"/utf8>>, begin gleam@dynamic@decode:field( <<"command"/utf8>>, gleam@dynamic@decode:list( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Command) -> gleam@dynamic@decode:field( <<"env"/utf8>>, gleam@dynamic@decode:dict( {decoder, fun gleam@dynamic@decode:decode_string/1}, {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Env) -> gleam@dynamic@decode:optional_field( <<"timeout_ms"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun( Timeout_ms ) -> gleam@dynamic@decode:optional_field( <<"user"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( User ) -> gleam@dynamic@decode:optional_field( <<"working_directory"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Working_directory ) -> gleam@dynamic@decode:success( {local_shell_exec_action, Command, Env, Timeout_ms, User, Working_directory} ) end ) end ) end ) end ) end ) end, fun(Action) -> gleam@dynamic@decode:success( {output_item_local_shell_call, {local_shell_tool_call, Action, Call_id@1, Id@2, Status@2}} ) end ) end ) end ) end ); <<"mcp_list_tools"/utf8>> -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id@3) -> gleam@dynamic@decode:field( <<"server_label"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Server_label) -> gleam@dynamic@decode:field( <<"tools"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Tools) -> gleam@dynamic@decode:optional_field( <<"error"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Error) -> gleam@dynamic@decode:success( {output_item_mcp_list_tools, {mcp_list_tools, Id@3, Server_label, Tools, Error}} ) end ) end ) end ) end ); <<"mcp_approval_request"/utf8>> -> gleam@dynamic@decode:field( <<"arguments"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Arguments) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id@4) -> gleam@dynamic@decode:field( <<"name"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Name) -> gleam@dynamic@decode:field( <<"server_label"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Server_label@1) -> gleam@dynamic@decode:success( {output_item_mcp_approval_request, {mcp_approval_request, Arguments, Id@4, Name, Server_label@1}} ) end ) end ) end ) end ); <<"tool_search_call"/utf8>> -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id@5) -> gleam@dynamic@decode:optional_field( <<"call_id"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Call_id@2) -> gleam@dynamic@decode:field( <<"execution"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value@1) -> case Value@1 of <<"server"/utf8>> -> gleam@dynamic@decode:success( execution_server ); <<"client"/utf8>> -> gleam@dynamic@decode:success( execution_client ); _ -> gleam@dynamic@decode:failure( execution_server, <<"ToolSearchExecutionType"/utf8>> ) end end ) end, fun(Execution) -> gleam@dynamic@decode:field( <<"arguments"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Arguments@1) -> gleam@dynamic@decode:field( <<"status"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value@2) -> case Value@2 of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success( function_call_in_progress ); <<"completed"/utf8>> -> gleam@dynamic@decode:success( function_call_completed ); <<"incomplete"/utf8>> -> gleam@dynamic@decode:success( function_call_incomplete ); _ -> gleam@dynamic@decode:failure( function_call_in_progress, <<"FunctionCallStatus"/utf8>> ) end end ) end, fun(Status@3) -> gleam@dynamic@decode:optional_field( <<"created_by"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Created_by) -> gleam@dynamic@decode:success( {output_item_tool_search_call, {tool_search_call, Id@5, Call_id@2, Execution, Arguments@1, Status@3, Created_by}} ) end ) end ) end ) end ) end ) end ); <<"tool_search_output"/utf8>> -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id@6) -> gleam@dynamic@decode:optional_field( <<"call_id"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Call_id@3) -> gleam@dynamic@decode:field( <<"execution"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value@3) -> case Value@3 of <<"server"/utf8>> -> gleam@dynamic@decode:success( execution_server ); <<"client"/utf8>> -> gleam@dynamic@decode:success( execution_client ); _ -> gleam@dynamic@decode:failure( execution_server, <<"ToolSearchExecutionType"/utf8>> ) end end ) end, fun(Execution@1) -> gleam@dynamic@decode:field( <<"tools"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Tools@1) -> gleam@dynamic@decode:field( <<"status"/utf8>>, begin gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Value@4) -> case Value@4 of <<"in_progress"/utf8>> -> gleam@dynamic@decode:success( function_call_in_progress ); <<"completed"/utf8>> -> gleam@dynamic@decode:success( function_call_completed ); <<"incomplete"/utf8>> -> gleam@dynamic@decode:success( function_call_incomplete ); _ -> gleam@dynamic@decode:failure( function_call_in_progress, <<"FunctionCallStatus"/utf8>> ) end end ) end, fun(Status@4) -> gleam@dynamic@decode:optional_field( <<"created_by"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Created_by@1 ) -> gleam@dynamic@decode:success( {output_item_tool_search_output, {tool_search_output, Id@6, Call_id@3, Execution@1, Tools@1, Status@4, Created_by@1}} ) end ) end ) end ) end ) end ) end ); _ -> gleam@dynamic@decode:then( {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(_) -> gleam@dynamic@decode:failure( {output_item_message, {output_message, [], <<""/utf8>>, role_assistant, none, output_completed}}, <<<<"OutputItem (unknown type: "/utf8, Tag/binary>>/binary, ")"/utf8>> ) end ) end end ). -file("src/glopenai/response.gleam", 3844). -spec conversation_decoder() -> gleam@dynamic@decode:decoder(conversation()). conversation_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:success({conversation, Id}) end ). -file("src/glopenai/response.gleam", 3849). -spec error_object_decoder() -> gleam@dynamic@decode:decoder(error_object()). error_object_decoder() -> gleam@dynamic@decode:field( <<"code"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Code) -> gleam@dynamic@decode:field( <<"message"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Message) -> gleam@dynamic@decode:success({error_object, Code, Message}) end ) end ). -file("src/glopenai/response.gleam", 3855). -spec prompt_decoder() -> gleam@dynamic@decode:decoder(prompt()). prompt_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:optional_field( <<"version"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Version) -> gleam@dynamic@decode:optional_field( <<"variables"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_dynamic/1} ), fun(Variables) -> gleam@dynamic@decode:success( {prompt, Id, Version, Variables} ) end ) end ) end ). -file("src/glopenai/response.gleam", 3870). -spec response_decoder() -> gleam@dynamic@decode:decoder(response()). response_decoder() -> gleam@dynamic@decode:optional_field( <<"background"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_bool/1} ), fun(Background) -> gleam@dynamic@decode:optional_field( <<"billing"/utf8>>, none, gleam@dynamic@decode:optional( begin gleam@dynamic@decode:field( <<"payer"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Payer) -> gleam@dynamic@decode:success({billing, Payer}) end ) end ), fun(Billing) -> gleam@dynamic@decode:optional_field( <<"conversation"/utf8>>, none, gleam@dynamic@decode:optional(conversation_decoder()), fun(Conversation) -> gleam@dynamic@decode:field( <<"created_at"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Created_at) -> gleam@dynamic@decode:optional_field( <<"completed_at"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun(Completed_at) -> gleam@dynamic@decode:optional_field( <<"error"/utf8>>, none, gleam@dynamic@decode:optional( error_object_decoder() ), fun(Error) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:optional_field( <<"incomplete_details"/utf8>>, none, gleam@dynamic@decode:optional( begin gleam@dynamic@decode:field( <<"reason"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Reason ) -> gleam@dynamic@decode:success( {incomplete_details, Reason} ) end ) end ), fun( Incomplete_details ) -> gleam@dynamic@decode:optional_field( <<"instructions"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:one_of( begin _pipe = {decoder, fun gleam@dynamic@decode:decode_string/1}, gleam@dynamic@decode:then( _pipe, fun( S ) -> gleam@dynamic@decode:success( {instructions_text, S} ) end ) end, [begin _pipe@1 = {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, gleam@dynamic@decode:then( _pipe@1, fun( _ ) -> gleam@dynamic@decode:success( {instructions_text, <<""/utf8>>} ) end ) end] ) ), fun( Instructions ) -> gleam@dynamic@decode:optional_field( <<"max_output_tokens"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun( Max_output_tokens ) -> gleam@dynamic@decode:optional_field( <<"metadata"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:dict( {decoder, fun gleam@dynamic@decode:decode_string/1}, {decoder, fun gleam@dynamic@decode:decode_string/1} ) ), fun( Metadata ) -> gleam@dynamic@decode:field( <<"model"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Model ) -> gleam@dynamic@decode:field( <<"object"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun( Object ) -> gleam@dynamic@decode:field( <<"output"/utf8>>, gleam@dynamic@decode:list( output_item_decoder( ) ), fun( Output ) -> gleam@dynamic@decode:optional_field( <<"parallel_tool_calls"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_bool/1} ), fun( Parallel_tool_calls ) -> gleam@dynamic@decode:optional_field( <<"previous_response_id"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Previous_response_id ) -> gleam@dynamic@decode:optional_field( <<"prompt"/utf8>>, none, gleam@dynamic@decode:optional( prompt_decoder( ) ), fun( Prompt ) -> gleam@dynamic@decode:optional_field( <<"prompt_cache_key"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Prompt_cache_key ) -> gleam@dynamic@decode:optional_field( <<"prompt_cache_retention"/utf8>>, none, gleam@dynamic@decode:optional( prompt_cache_retention_decoder( ) ), fun( Prompt_cache_retention ) -> gleam@dynamic@decode:optional_field( <<"reasoning"/utf8>>, none, gleam@dynamic@decode:optional( reasoning_decoder( ) ), fun( Reasoning ) -> gleam@dynamic@decode:optional_field( <<"safety_identifier"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun( Safety_identifier ) -> gleam@dynamic@decode:optional_field( <<"service_tier"/utf8>>, none, gleam@dynamic@decode:optional( service_tier_decoder( ) ), fun( Service_tier ) -> gleam@dynamic@decode:field( <<"status"/utf8>>, response_status_decoder( ), fun( Status ) -> gleam@dynamic@decode:optional_field( <<"temperature"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_float/1} ), fun( Temperature ) -> gleam@dynamic@decode:optional_field( <<"text"/utf8>>, none, gleam@dynamic@decode:optional( response_text_param_decoder( ) ), fun( Text ) -> gleam@dynamic@decode:optional_field( <<"tool_choice"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_dynamic/1} ), fun( _ ) -> gleam@dynamic@decode:optional_field( <<"tools"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_dynamic/1} ), fun( _ ) -> gleam@dynamic@decode:optional_field( <<"top_logprobs"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_int/1} ), fun( Top_logprobs ) -> gleam@dynamic@decode:optional_field( <<"top_p"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_float/1} ), fun( Top_p ) -> gleam@dynamic@decode:optional_field( <<"truncation"/utf8>>, none, gleam@dynamic@decode:optional( truncation_decoder( ) ), fun( Truncation ) -> gleam@dynamic@decode:optional_field( <<"usage"/utf8>>, none, gleam@dynamic@decode:optional( glopenai@shared:response_usage_decoder( ) ), fun( Usage ) -> gleam@dynamic@decode:success( {response, Background, Billing, Conversation, Created_at, Completed_at, Error, Id, Incomplete_details, Instructions, Max_output_tokens, Metadata, Model, Object, Output, Parallel_tool_calls, Previous_response_id, Prompt, Prompt_cache_key, Prompt_cache_retention, Reasoning, Safety_identifier, Service_tier, Status, Temperature, Text, none, none, Top_logprobs, Top_p, Truncation, Usage} ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 4058). -spec delete_response_decoder() -> gleam@dynamic@decode:decoder(delete_response()). delete_response_decoder() -> gleam@dynamic@decode:field( <<"object"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Object) -> gleam@dynamic@decode:field( <<"deleted"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_bool/1}, fun(Deleted) -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:success( {delete_response, Object, Deleted, Id} ) end ) end ) end ). -file("src/glopenai/response.gleam", 4065). -spec response_item_list_decoder() -> gleam@dynamic@decode:decoder(response_item_list()). response_item_list_decoder() -> gleam@dynamic@decode:field( <<"object"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Object) -> gleam@dynamic@decode:optional_field( <<"first_id"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(First_id) -> gleam@dynamic@decode:optional_field( <<"last_id"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Last_id) -> gleam@dynamic@decode:field( <<"has_more"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_bool/1}, fun(Has_more) -> gleam@dynamic@decode:field( <<"data"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Data) -> gleam@dynamic@decode:success( {response_item_list, Object, First_id, Last_id, Has_more, Data} ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 4088). -spec token_counts_resource_decoder() -> gleam@dynamic@decode:decoder(token_counts_resource()). token_counts_resource_decoder() -> gleam@dynamic@decode:field( <<"object"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Object) -> gleam@dynamic@decode:field( <<"input_tokens"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Input_tokens) -> gleam@dynamic@decode:success( {token_counts_resource, Object, Input_tokens} ) end ) end ). -file("src/glopenai/response.gleam", 4094). -spec compact_resource_decoder() -> gleam@dynamic@decode:decoder(compact_resource()). compact_resource_decoder() -> gleam@dynamic@decode:field( <<"id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Id) -> gleam@dynamic@decode:field( <<"object"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Object) -> gleam@dynamic@decode:field( <<"output"/utf8>>, gleam@dynamic@decode:list(output_item_decoder()), fun(Output) -> gleam@dynamic@decode:field( <<"created_at"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Created_at) -> gleam@dynamic@decode:field( <<"usage"/utf8>>, glopenai@shared:response_usage_decoder(), fun(Usage) -> gleam@dynamic@decode:success( {compact_resource, Id, Object, Output, Created_at, Usage} ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 4508). -spec response_event_with_response( fun((integer(), response()) -> response_stream_event()) ) -> gleam@dynamic@decode:decoder(response_stream_event()). response_event_with_response(Constructor) -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number) -> gleam@dynamic@decode:field( <<"response"/utf8>>, response_decoder(), fun(Resp) -> gleam@dynamic@decode:success( Constructor(Sequence_number, Resp) ) end ) end ). -file("src/glopenai/response.gleam", 4516). -spec simple_status_event( fun((integer(), integer(), binary()) -> response_stream_event()) ) -> gleam@dynamic@decode:decoder(response_stream_event()). simple_status_event(Constructor) -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id) -> gleam@dynamic@decode:success( Constructor( Sequence_number, Output_index, Item_id ) ) end ) end ) end ). -file("src/glopenai/response.gleam", 4525). -spec output_index_delta_event( fun((integer(), integer(), binary(), binary()) -> response_stream_event()) ) -> gleam@dynamic@decode:decoder(response_stream_event()). output_index_delta_event(Constructor) -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id) -> gleam@dynamic@decode:field( <<"delta"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Delta) -> gleam@dynamic@decode:success( Constructor( Sequence_number, Output_index, Item_id, Delta ) ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 4535). -spec text_delta_event( fun((integer(), binary(), integer(), integer(), binary(), gleam@option:option(list(response_log_prob()))) -> response_stream_event()) ) -> gleam@dynamic@decode:decoder(response_stream_event()). text_delta_event(Constructor) -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index) -> gleam@dynamic@decode:field( <<"delta"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Delta) -> gleam@dynamic@decode:optional_field( <<"logprobs"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:list( response_log_prob_decoder( ) ) ), fun(Logprobs) -> gleam@dynamic@decode:success( Constructor( Sequence_number, Item_id, Output_index, Content_index, Delta, Logprobs ) ) end ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 4559). -spec summary_text_delta_event( fun((integer(), binary(), integer(), integer(), binary()) -> response_stream_event()) ) -> gleam@dynamic@decode:decoder(response_stream_event()). summary_text_delta_event(Constructor) -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index) -> gleam@dynamic@decode:field( <<"summary_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Summary_index) -> gleam@dynamic@decode:field( <<"delta"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Delta) -> gleam@dynamic@decode:success( Constructor( Sequence_number, Item_id, Output_index, Summary_index, Delta ) ) end ) end ) end ) end ) end ). -file("src/glopenai/response.gleam", 4128). -spec response_stream_event_decoder() -> gleam@dynamic@decode:decoder(response_stream_event()). response_stream_event_decoder() -> gleam@dynamic@decode:field( <<"type"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Tag) -> case Tag of <<"response.created"/utf8>> -> response_event_with_response( fun(Field@0, Field@1) -> {event_response_created, Field@0, Field@1} end ); <<"response.in_progress"/utf8>> -> response_event_with_response( fun(Field@0, Field@1) -> {event_response_in_progress, Field@0, Field@1} end ); <<"response.completed"/utf8>> -> response_event_with_response( fun(Field@0, Field@1) -> {event_response_completed, Field@0, Field@1} end ); <<"response.failed"/utf8>> -> response_event_with_response( fun(Field@0, Field@1) -> {event_response_failed, Field@0, Field@1} end ); <<"response.incomplete"/utf8>> -> response_event_with_response( fun(Field@0, Field@1) -> {event_response_incomplete, Field@0, Field@1} end ); <<"response.queued"/utf8>> -> response_event_with_response( fun(Field@0, Field@1) -> {event_response_queued, Field@0, Field@1} end ); <<"response.output_item.added"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index) -> gleam@dynamic@decode:field( <<"item"/utf8>>, output_item_decoder(), fun(Item) -> gleam@dynamic@decode:success( {event_response_output_item_added, Sequence_number, Output_index, Item} ) end ) end ) end ); <<"response.output_item.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@1) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@1) -> gleam@dynamic@decode:field( <<"item"/utf8>>, output_item_decoder(), fun(Item@1) -> gleam@dynamic@decode:success( {event_response_output_item_done, Sequence_number@1, Output_index@1, Item@1} ) end ) end ) end ); <<"response.content_part.added"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@2) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@2) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index) -> gleam@dynamic@decode:field( <<"part"/utf8>>, output_content_decoder(), fun(Part) -> gleam@dynamic@decode:success( {event_response_content_part_added, Sequence_number@2, Item_id, Output_index@2, Content_index, Part} ) end ) end ) end ) end ) end ); <<"response.content_part.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@3) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@1) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@3) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index@1) -> gleam@dynamic@decode:field( <<"part"/utf8>>, output_content_decoder(), fun(Part@1) -> gleam@dynamic@decode:success( {event_response_content_part_done, Sequence_number@3, Item_id@1, Output_index@3, Content_index@1, Part@1} ) end ) end ) end ) end ) end ); <<"response.output_text.delta"/utf8>> -> text_delta_event( fun(Field@0, Field@1, Field@2, Field@3, Field@4, Field@5) -> {event_response_output_text_delta, Field@0, Field@1, Field@2, Field@3, Field@4, Field@5} end ); <<"response.output_text.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@4) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@2) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@4) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index@2) -> gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Text) -> gleam@dynamic@decode:optional_field( <<"logprobs"/utf8>>, none, gleam@dynamic@decode:optional( gleam@dynamic@decode:list( response_log_prob_decoder( ) ) ), fun(Logprobs) -> gleam@dynamic@decode:success( {event_response_output_text_done, Sequence_number@4, Item_id@2, Output_index@4, Content_index@2, Text, Logprobs} ) end ) end ) end ) end ) end ) end ); <<"response.refusal.delta"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@5) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@3) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@5) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index@3) -> gleam@dynamic@decode:field( <<"delta"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Delta) -> gleam@dynamic@decode:success( {event_response_refusal_delta, Sequence_number@5, Item_id@3, Output_index@5, Content_index@3, Delta} ) end ) end ) end ) end ) end ); <<"response.refusal.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@6) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@4) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@6) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index@4) -> gleam@dynamic@decode:field( <<"refusal"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Refusal) -> gleam@dynamic@decode:success( {event_response_refusal_done, Sequence_number@6, Item_id@4, Output_index@6, Content_index@4, Refusal} ) end ) end ) end ) end ) end ); <<"response.function_call_arguments.delta"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@7) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@5) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@7) -> gleam@dynamic@decode:field( <<"delta"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Delta@1) -> gleam@dynamic@decode:success( {event_response_function_call_arguments_delta, Sequence_number@7, Item_id@5, Output_index@7, Delta@1} ) end ) end ) end ) end ); <<"response.function_call_arguments.done"/utf8>> -> gleam@dynamic@decode:optional_field( <<"name"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Name) -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@8) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@6) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@8) -> gleam@dynamic@decode:field( <<"arguments"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Arguments) -> gleam@dynamic@decode:success( {event_response_function_call_arguments_done, Name, Sequence_number@8, Item_id@6, Output_index@8, Arguments} ) end ) end ) end ) end ) end ); <<"response.file_search_call.in_progress"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_file_search_call_in_progress, Field@0, Field@1, Field@2} end ); <<"response.file_search_call.searching"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_file_search_call_searching, Field@0, Field@1, Field@2} end ); <<"response.file_search_call.completed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_file_search_call_completed, Field@0, Field@1, Field@2} end ); <<"response.web_search_call.in_progress"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_web_search_call_in_progress, Field@0, Field@1, Field@2} end ); <<"response.web_search_call.searching"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_web_search_call_searching, Field@0, Field@1, Field@2} end ); <<"response.web_search_call.completed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_web_search_call_completed, Field@0, Field@1, Field@2} end ); <<"response.image_generation_call.completed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_image_gen_call_completed, Field@0, Field@1, Field@2} end ); <<"response.image_generation_call.generating"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_image_gen_call_generating, Field@0, Field@1, Field@2} end ); <<"response.image_generation_call.in_progress"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_image_gen_call_in_progress, Field@0, Field@1, Field@2} end ); <<"response.mcp_call.completed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_mcp_call_completed, Field@0, Field@1, Field@2} end ); <<"response.mcp_call.failed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_mcp_call_failed, Field@0, Field@1, Field@2} end ); <<"response.mcp_call.in_progress"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_mcp_call_in_progress, Field@0, Field@1, Field@2} end ); <<"response.mcp_list_tools.completed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_mcp_list_tools_completed, Field@0, Field@1, Field@2} end ); <<"response.mcp_list_tools.failed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_mcp_list_tools_failed, Field@0, Field@1, Field@2} end ); <<"response.mcp_list_tools.in_progress"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_mcp_list_tools_in_progress, Field@0, Field@1, Field@2} end ); <<"response.code_interpreter_call.in_progress"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_code_interpreter_call_in_progress, Field@0, Field@1, Field@2} end ); <<"response.code_interpreter_call.interpreting"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_code_interpreter_call_interpreting, Field@0, Field@1, Field@2} end ); <<"response.code_interpreter_call.completed"/utf8>> -> simple_status_event( fun(Field@0, Field@1, Field@2) -> {event_response_code_interpreter_call_completed, Field@0, Field@1, Field@2} end ); <<"response.mcp_call_arguments.delta"/utf8>> -> output_index_delta_event( fun(Field@0, Field@1, Field@2, Field@3) -> {event_response_mcp_call_arguments_delta, Field@0, Field@1, Field@2, Field@3} end ); <<"response.mcp_call_arguments.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@9) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@9) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@7) -> gleam@dynamic@decode:field( <<"arguments"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Arguments@1) -> gleam@dynamic@decode:success( {event_response_mcp_call_arguments_done, Sequence_number@9, Output_index@9, Item_id@7, Arguments@1} ) end ) end ) end ) end ); <<"response.code_interpreter_call_code.delta"/utf8>> -> output_index_delta_event( fun(Field@0, Field@1, Field@2, Field@3) -> {event_response_code_interpreter_call_code_delta, Field@0, Field@1, Field@2, Field@3} end ); <<"response.code_interpreter_call_code.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@10) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@10) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@8) -> gleam@dynamic@decode:field( <<"code"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Code) -> gleam@dynamic@decode:success( {event_response_code_interpreter_call_code_done, Sequence_number@10, Output_index@10, Item_id@8, Code} ) end ) end ) end ) end ); <<"response.reasoning_summary_part.added"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@11) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@9) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@11) -> gleam@dynamic@decode:field( <<"summary_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Summary_index) -> gleam@dynamic@decode:field( <<"part"/utf8>>, summary_part_decoder(), fun(Part@2) -> gleam@dynamic@decode:success( {event_response_reasoning_summary_part_added, Sequence_number@11, Item_id@9, Output_index@11, Summary_index, Part@2} ) end ) end ) end ) end ) end ); <<"response.reasoning_summary_part.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@12) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@10) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@12) -> gleam@dynamic@decode:field( <<"summary_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Summary_index@1) -> gleam@dynamic@decode:field( <<"part"/utf8>>, summary_part_decoder(), fun(Part@3) -> gleam@dynamic@decode:success( {event_response_reasoning_summary_part_done, Sequence_number@12, Item_id@10, Output_index@12, Summary_index@1, Part@3} ) end ) end ) end ) end ) end ); <<"response.reasoning_summary_text.delta"/utf8>> -> summary_text_delta_event( fun(Field@0, Field@1, Field@2, Field@3, Field@4) -> {event_response_reasoning_summary_text_delta, Field@0, Field@1, Field@2, Field@3, Field@4} end ); <<"response.reasoning_summary_text.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@13) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@11) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@13) -> gleam@dynamic@decode:field( <<"summary_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Summary_index@2) -> gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Text@1) -> gleam@dynamic@decode:success( {event_response_reasoning_summary_text_done, Sequence_number@13, Item_id@11, Output_index@13, Summary_index@2, Text@1} ) end ) end ) end ) end ) end ); <<"response.reasoning_text.delta"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@14) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@12) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@14) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index@5) -> gleam@dynamic@decode:field( <<"delta"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Delta@2) -> gleam@dynamic@decode:success( {event_response_reasoning_text_delta, Sequence_number@14, Item_id@12, Output_index@14, Content_index@5, Delta@2} ) end ) end ) end ) end ) end ); <<"response.reasoning_text.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@15) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@13) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@15) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index@6) -> gleam@dynamic@decode:field( <<"text"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Text@2) -> gleam@dynamic@decode:success( {event_response_reasoning_text_done, Sequence_number@15, Item_id@13, Output_index@15, Content_index@6, Text@2} ) end ) end ) end ) end ) end ); <<"response.image_generation_call.partial_image"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@16) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@16) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@14) -> gleam@dynamic@decode:field( <<"partial_image_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Partial_image_index) -> gleam@dynamic@decode:field( <<"partial_image_b64"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Partial_image_b64) -> gleam@dynamic@decode:success( {event_response_image_gen_call_partial_image, Sequence_number@16, Output_index@16, Item_id@14, Partial_image_index, Partial_image_b64} ) end ) end ) end ) end ) end ); <<"response.output_text.annotation.added"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@17) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@17) -> gleam@dynamic@decode:field( <<"content_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Content_index@7) -> gleam@dynamic@decode:field( <<"annotation_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Annotation_index) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@15) -> gleam@dynamic@decode:field( <<"annotation"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_dynamic/1}, fun(Annotation) -> gleam@dynamic@decode:success( {event_response_output_text_annotation_added, Sequence_number@17, Output_index@17, Content_index@7, Annotation_index, Item_id@15, Annotation} ) end ) end ) end ) end ) end ) end ); <<"response.custom_tool_call_input.delta"/utf8>> -> output_index_delta_event( fun(Field@0, Field@1, Field@2, Field@3) -> {event_response_custom_tool_call_input_delta, Field@0, Field@1, Field@2, Field@3} end ); <<"response.custom_tool_call_input.done"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@18) -> gleam@dynamic@decode:field( <<"output_index"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Output_index@18) -> gleam@dynamic@decode:field( <<"item_id"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Item_id@16) -> gleam@dynamic@decode:field( <<"input"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Input) -> gleam@dynamic@decode:success( {event_response_custom_tool_call_input_done, Sequence_number@18, Output_index@18, Item_id@16, Input} ) end ) end ) end ) end ); <<"error"/utf8>> -> gleam@dynamic@decode:field( <<"sequence_number"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_int/1}, fun(Sequence_number@19) -> gleam@dynamic@decode:optional_field( <<"code"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Code@1) -> gleam@dynamic@decode:field( <<"message"/utf8>>, {decoder, fun gleam@dynamic@decode:decode_string/1}, fun(Message) -> gleam@dynamic@decode:optional_field( <<"param"/utf8>>, none, gleam@dynamic@decode:optional( {decoder, fun gleam@dynamic@decode:decode_string/1} ), fun(Param) -> gleam@dynamic@decode:success( {event_response_error, Sequence_number@19, Code@1, Message, Param} ) end ) end ) end ) end ); _ -> gleam@dynamic@decode:failure( {event_response_error, 0, none, <<"unknown event type: "/utf8, Tag/binary>>, none}, <<"ResponseStreamEvent"/utf8>> ) end end ). -file("src/glopenai/response.gleam", 4115). ?DOC( " Parse a single SSE data line from the Responses API streaming endpoint.\n" " Returns `Ok(Some(event))` for data, `Ok(None)` for the [DONE] sentinel.\n" ). -spec parse_stream_event(binary()) -> {ok, gleam@option:option(response_stream_event())} | {error, glopenai@error:glopenai_error()}. parse_stream_event(Data) -> case Data of <<"[DONE]"/utf8>> -> {ok, none}; _ -> case gleam@json:parse(Data, response_stream_event_decoder()) of {ok, Event} -> {ok, {some, Event}}; {error, Decode_error} -> {error, {json_decode_error, Data, Decode_error}} end end. -file("src/glopenai/response.gleam", 4581). ?DOC(" Build a request to create a response.\n"). -spec create_request(glopenai@config:config(), create_response()) -> gleam@http@request:request(binary()). create_request(Config, Params) -> glopenai@internal:post_request( Config, <<"/responses"/utf8>>, create_response_to_json(Params) ). -file("src/glopenai/response.gleam", 4586). ?DOC(" Parse the response from creating a response.\n"). -spec create_response_response(gleam@http@response:response(binary())) -> {ok, response()} | {error, glopenai@error:glopenai_error()}. create_response_response(Response) -> glopenai@internal:parse_response(Response, response_decoder()). -file("src/glopenai/response.gleam", 4593). ?DOC(" Build a request to retrieve a response by ID.\n"). -spec retrieve_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()). retrieve_request(Config, Response_id) -> glopenai@internal:get_request( Config, <<"/responses/"/utf8, Response_id/binary>> ). -file("src/glopenai/response.gleam", 4598). ?DOC(" Parse the response from retrieving a response.\n"). -spec retrieve_response(gleam@http@response:response(binary())) -> {ok, response()} | {error, glopenai@error:glopenai_error()}. retrieve_response(Response) -> glopenai@internal:parse_response(Response, response_decoder()). -file("src/glopenai/response.gleam", 4605). ?DOC(" Build a request to delete a response by ID.\n"). -spec delete_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()). delete_request(Config, Response_id) -> glopenai@internal:delete_request( Config, <<"/responses/"/utf8, Response_id/binary>> ). -file("src/glopenai/response.gleam", 4610). ?DOC(" Parse the response from deleting a response.\n"). -spec delete_response(gleam@http@response:response(binary())) -> {ok, delete_response()} | {error, glopenai@error:glopenai_error()}. delete_response(Response) -> glopenai@internal:parse_response(Response, delete_response_decoder()). -file("src/glopenai/response.gleam", 4617). ?DOC(" Build a request to cancel a background response.\n"). -spec cancel_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()). cancel_request(Config, Response_id) -> glopenai@internal:post_request( Config, <<<<"/responses/"/utf8, Response_id/binary>>/binary, "/cancel"/utf8>>, gleam@json:object([]) ). -file("src/glopenai/response.gleam", 4626). ?DOC(" Parse the response from cancelling a response.\n"). -spec cancel_response(gleam@http@response:response(binary())) -> {ok, response()} | {error, glopenai@error:glopenai_error()}. cancel_response(Response) -> glopenai@internal:parse_response(Response, response_decoder()). -file("src/glopenai/response.gleam", 4633). ?DOC(" Build a request to list input items for a response.\n"). -spec list_input_items_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()). list_input_items_request(Config, Response_id) -> glopenai@internal:get_request( Config, <<<<"/responses/"/utf8, Response_id/binary>>/binary, "/input_items"/utf8>> ). -file("src/glopenai/response.gleam", 4641). ?DOC(" Parse the response from listing input items.\n"). -spec list_input_items_response(gleam@http@response:response(binary())) -> {ok, response_item_list()} | {error, glopenai@error:glopenai_error()}. list_input_items_response(Response) -> glopenai@internal:parse_response(Response, response_item_list_decoder()). -file("src/glopenai/response.gleam", 4648). ?DOC(" Build a request to count input tokens.\n"). -spec get_input_token_counts_request( glopenai@config:config(), gleam@json:json() ) -> gleam@http@request:request(binary()). get_input_token_counts_request(Config, Body) -> glopenai@internal:post_request( Config, <<"/responses/input_tokens"/utf8>>, Body ). -file("src/glopenai/response.gleam", 4656). ?DOC(" Parse the response from counting input tokens.\n"). -spec get_input_token_counts_response(gleam@http@response:response(binary())) -> {ok, token_counts_resource()} | {error, glopenai@error:glopenai_error()}. get_input_token_counts_response(Response) -> glopenai@internal:parse_response(Response, token_counts_resource_decoder()). -file("src/glopenai/response.gleam", 4663). ?DOC(" Build a request to compact a conversation.\n"). -spec compact_request(glopenai@config:config(), gleam@json:json()) -> gleam@http@request:request(binary()). compact_request(Config, Body) -> glopenai@internal:post_request(Config, <<"/responses/compact"/utf8>>, Body). -file("src/glopenai/response.gleam", 4668). ?DOC(" Parse the response from compacting a conversation.\n"). -spec compact_response(gleam@http@response:response(binary())) -> {ok, compact_resource()} | {error, glopenai@error:glopenai_error()}. compact_response(Response) -> glopenai@internal:parse_response(Response, compact_resource_decoder()).