anthropic 1.1.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +170 -0
- data/README.md +32 -16
- data/lib/anthropic/client.rb +5 -2
- data/lib/anthropic/errors.rb +22 -0
- data/lib/anthropic/helpers/bedrock/client.rb +34 -4
- data/lib/anthropic/helpers/input_schema/array_of.rb +41 -0
- data/lib/anthropic/helpers/input_schema/base_model.rb +86 -0
- data/lib/anthropic/helpers/input_schema/boolean.rb +29 -0
- data/lib/anthropic/helpers/input_schema/enum_of.rb +63 -0
- data/lib/anthropic/helpers/input_schema/json_schema_converter.rb +199 -0
- data/lib/anthropic/helpers/input_schema/parsed_json.rb +39 -0
- data/lib/anthropic/helpers/input_schema/property_mapping.rb +47 -0
- data/lib/anthropic/helpers/input_schema/union_of.rb +56 -0
- data/lib/anthropic/helpers/input_schema.rb +16 -0
- data/lib/anthropic/helpers/streaming/events.rb +141 -0
- data/lib/anthropic/helpers/streaming/message_stream.rb +278 -0
- data/lib/anthropic/helpers/streaming.rb +37 -0
- data/lib/anthropic/helpers/vertex/client.rb +4 -1
- data/lib/anthropic/input_schema.rb +10 -0
- data/lib/anthropic/internal/stream.rb +6 -3
- data/lib/anthropic/internal/transport/base_client.rb +30 -5
- data/lib/anthropic/internal/transport/pooled_net_requester.rb +1 -9
- data/lib/anthropic/internal/type/array_of.rb +7 -1
- data/lib/anthropic/internal/type/base_model.rb +81 -32
- data/lib/anthropic/internal/type/base_stream.rb +3 -1
- data/lib/anthropic/internal/type/boolean.rb +7 -1
- data/lib/anthropic/internal/type/converter.rb +69 -34
- data/lib/anthropic/internal/type/enum.rb +16 -5
- data/lib/anthropic/internal/type/file_input.rb +6 -1
- data/lib/anthropic/internal/type/hash_of.rb +7 -1
- data/lib/anthropic/internal/type/union.rb +26 -16
- data/lib/anthropic/internal/type/unknown.rb +7 -1
- data/lib/anthropic/internal/util.rb +10 -11
- data/lib/anthropic/models/anthropic_beta.rb +3 -0
- data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +1 -65
- data/lib/anthropic/models/beta/beta_bash_code_execution_output_block.rb +25 -0
- data/lib/anthropic/models/beta/beta_bash_code_execution_output_block_param.rb +25 -0
- data/lib/anthropic/models/beta/beta_bash_code_execution_result_block.rb +44 -0
- data/lib/anthropic/models/beta/beta_bash_code_execution_result_block_param.rb +44 -0
- data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rb +43 -0
- data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rb +53 -0
- data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rb +39 -0
- data/lib/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rb +39 -0
- data/lib/anthropic/models/beta/beta_citation_char_location.rb +7 -1
- data/lib/anthropic/models/beta/beta_citation_config.rb +19 -0
- data/lib/anthropic/models/beta/beta_citation_content_block_location.rb +7 -1
- data/lib/anthropic/models/beta/beta_citation_page_location.rb +7 -1
- data/lib/anthropic/models/beta/beta_citation_search_result_location.rb +55 -0
- data/lib/anthropic/models/beta/beta_citation_search_result_location_param.rb +55 -0
- data/lib/anthropic/models/beta/beta_citations_delta.rb +5 -3
- data/lib/anthropic/models/beta/beta_code_execution_tool_20250825.rb +40 -0
- data/lib/anthropic/models/beta/beta_content_block.rb +12 -5
- data/lib/anthropic/models/beta/beta_content_block_param.rb +28 -17
- data/lib/anthropic/models/beta/beta_document_block.rb +56 -0
- data/lib/anthropic/models/beta/beta_message.rb +6 -2
- data/lib/anthropic/models/beta/beta_message_param.rb +3 -3
- data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +14 -7
- data/lib/anthropic/models/beta/beta_request_document_block.rb +75 -0
- data/lib/anthropic/models/beta/beta_search_result_block_param.rb +55 -0
- data/lib/anthropic/models/beta/beta_server_tool_usage.rb +9 -1
- data/lib/anthropic/models/beta/beta_server_tool_use_block.rb +3 -0
- data/lib/anthropic/models/beta/beta_server_tool_use_block_param.rb +3 -0
- data/lib/anthropic/models/beta/beta_text_block.rb +2 -2
- data/lib/anthropic/models/beta/beta_text_block_param.rb +2 -2
- data/lib/anthropic/models/beta/beta_text_citation.rb +3 -1
- data/lib/anthropic/models/beta/beta_text_citation_param.rb +3 -1
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rb +25 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rb +26 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rb +49 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rb +50 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rb +47 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rb +57 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rb +45 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rb +46 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rb +61 -0
- data/lib/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rb +62 -0
- data/lib/anthropic/models/beta/beta_tool.rb +7 -1
- data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +8 -4
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +49 -0
- data/lib/anthropic/models/beta/beta_tool_union.rb +12 -6
- data/lib/anthropic/models/beta/beta_web_fetch_block.rb +42 -0
- data/lib/anthropic/models/beta/beta_web_fetch_block_param.rb +42 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_20250910.rb +82 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_result_block.rb +43 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_result_block_param.rb +53 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_result_error_block.rb +25 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_result_error_block_param.rb +25 -0
- data/lib/anthropic/models/beta/beta_web_fetch_tool_result_error_code.rb +25 -0
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +23 -36
- data/lib/anthropic/models/beta/message_create_params.rb +10 -27
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +13 -37
- data/lib/anthropic/models/beta/messages/beta_message_batch.rb +1 -4
- data/lib/anthropic/models/beta_error_response.rb +7 -1
- data/lib/anthropic/models/cache_control_ephemeral.rb +39 -1
- data/lib/anthropic/models/cache_creation.rb +24 -0
- data/lib/anthropic/models/citation_char_location.rb +7 -1
- data/lib/anthropic/models/citation_content_block_location.rb +7 -1
- data/lib/anthropic/models/citation_page_location.rb +7 -1
- data/lib/anthropic/models/citation_search_result_location_param.rb +51 -0
- data/lib/anthropic/models/citations_delta.rb +5 -3
- data/lib/anthropic/models/citations_search_result_location.rb +51 -0
- data/lib/anthropic/models/content_block.rb +5 -5
- data/lib/anthropic/models/content_block_param.rb +14 -11
- data/lib/anthropic/models/document_block_param.rb +2 -2
- data/lib/anthropic/models/error_response.rb +7 -1
- data/lib/anthropic/models/message.rb +6 -2
- data/lib/anthropic/models/message_count_tokens_params.rb +10 -27
- data/lib/anthropic/models/message_count_tokens_tool.rb +5 -1
- data/lib/anthropic/models/message_create_params.rb +10 -27
- data/lib/anthropic/models/message_param.rb +3 -3
- data/lib/anthropic/models/messages/batch_create_params.rb +11 -31
- data/lib/anthropic/models/model.rb +16 -21
- data/lib/anthropic/models/raw_content_block_start_event.rb +7 -7
- data/lib/anthropic/models/search_result_block_param.rb +51 -0
- data/lib/anthropic/models/text_block.rb +2 -2
- data/lib/anthropic/models/text_block_param.rb +2 -2
- data/lib/anthropic/models/text_citation.rb +3 -1
- data/lib/anthropic/models/text_citation_param.rb +3 -1
- data/lib/anthropic/models/tool.rb +7 -1
- data/lib/anthropic/models/tool_result_block_param.rb +8 -4
- data/lib/anthropic/models/tool_text_editor_20250429.rb +36 -0
- data/lib/anthropic/models/tool_text_editor_20250728.rb +45 -0
- data/lib/anthropic/models/tool_union.rb +5 -1
- data/lib/anthropic/models/tool_use_block.rb +14 -0
- data/lib/anthropic/models/usage.rb +9 -1
- data/lib/anthropic/models.rb +16 -4
- data/lib/anthropic/resources/beta/messages.rb +73 -6
- data/lib/anthropic/resources/messages.rb +152 -7
- data/lib/anthropic/streaming.rb +5 -0
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +54 -0
- data/rbi/anthropic/errors.rbi +18 -2
- data/rbi/anthropic/helpers/bedrock/client.rbi +17 -6
- data/rbi/anthropic/helpers/input_schema/array_of.rbi +16 -0
- data/rbi/anthropic/helpers/input_schema/base_model.rbi +21 -0
- data/rbi/anthropic/helpers/input_schema/boolean.rbi +11 -0
- data/rbi/anthropic/helpers/input_schema/enum_of.rbi +30 -0
- data/rbi/anthropic/helpers/input_schema/json_schema_converter.rbi +89 -0
- data/rbi/anthropic/helpers/input_schema/union_of.rbi +23 -0
- data/rbi/anthropic/helpers/streaming/events.rbi +95 -0
- data/rbi/anthropic/helpers/streaming/message_stream.rbi +73 -0
- data/rbi/anthropic/helpers/structured_output.rbi +16 -0
- data/rbi/anthropic/helpers/vertex/client.rbi +17 -6
- data/rbi/anthropic/input_schema.rbi +12 -0
- data/rbi/anthropic/internal/transport/base_client.rbi +1 -1
- data/rbi/anthropic/internal/type/base_stream.rbi +8 -1
- data/rbi/anthropic/internal/type/boolean.rbi +2 -0
- data/rbi/anthropic/internal/type/converter.rbi +69 -15
- data/rbi/anthropic/internal/type/union.rbi +14 -2
- data/rbi/anthropic/internal/type/unknown.rbi +2 -0
- data/rbi/anthropic/internal/util.rbi +2 -0
- data/rbi/anthropic/models/anthropic_beta.rbi +2 -0
- data/rbi/anthropic/models/beta/beta_base64_pdf_block.rbi +1 -128
- data/rbi/anthropic/models/beta/beta_bash_code_execution_output_block.rbi +33 -0
- data/rbi/anthropic/models/beta/beta_bash_code_execution_output_block_param.rbi +34 -0
- data/rbi/anthropic/models/beta/beta_bash_code_execution_result_block.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_bash_code_execution_result_block_param.rbi +77 -0
- data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rbi +86 -0
- data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rbi +110 -0
- data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rbi +101 -0
- data/rbi/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rbi +101 -0
- data/rbi/anthropic/models/beta/beta_citation_char_location.rbi +6 -0
- data/rbi/anthropic/models/beta/beta_citation_config.rbi +30 -0
- data/rbi/anthropic/models/beta/beta_citation_content_block_location.rbi +6 -0
- data/rbi/anthropic/models/beta/beta_citation_page_location.rbi +6 -0
- data/rbi/anthropic/models/beta/beta_citation_search_result_location.rbi +78 -0
- data/rbi/anthropic/models/beta/beta_citation_search_result_location_param.rbi +79 -0
- data/rbi/anthropic/models/beta/beta_citations_delta.rbi +4 -2
- data/rbi/anthropic/models/beta/beta_code_execution_tool_20250825.rbi +72 -0
- data/rbi/anthropic/models/beta/beta_content_block.rbi +6 -3
- data/rbi/anthropic/models/beta/beta_content_block_param.rbi +11 -7
- data/rbi/anthropic/models/beta/beta_document_block.rbi +95 -0
- data/rbi/anthropic/models/beta/beta_message.rbi +14 -3
- data/rbi/anthropic/models/beta/beta_raw_content_block_start_event.rbi +12 -6
- data/rbi/anthropic/models/beta/beta_request_document_block.rbi +142 -0
- data/rbi/anthropic/models/beta/beta_search_result_block_param.rbi +91 -0
- data/rbi/anthropic/models/beta/beta_server_tool_usage.rbi +17 -2
- data/rbi/anthropic/models/beta/beta_server_tool_use_block.rbi +15 -0
- data/rbi/anthropic/models/beta/beta_server_tool_use_block_param.rbi +15 -0
- data/rbi/anthropic/models/beta/beta_text_block.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_text_block_param.rbi +6 -3
- data/rbi/anthropic/models/beta/beta_text_citation.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_text_citation_param.rbi +2 -1
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rbi +41 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rbi +41 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rbi +73 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rbi +73 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rbi +90 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rbi +118 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rbi +110 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rbi +110 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rbi +118 -0
- data/rbi/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rbi +118 -0
- data/rbi/anthropic/models/beta/beta_tool.rbi +14 -5
- data/rbi/anthropic/models/beta/beta_tool_result_block_param.rbi +3 -1
- data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +82 -0
- data/rbi/anthropic/models/beta/beta_tool_union.rbi +7 -4
- data/rbi/anthropic/models/beta/beta_web_fetch_block.rbi +67 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_block_param.rbi +71 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_20250910.rbi +125 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_result_block.rbi +81 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_result_block_param.rbi +109 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_result_error_block.rbi +51 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_result_error_block_param.rbi +50 -0
- data/rbi/anthropic/models/beta/beta_web_fetch_tool_result_error_code.rbi +70 -0
- data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +51 -70
- data/rbi/anthropic/models/beta/message_create_params.rbi +44 -66
- data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +44 -66
- data/rbi/anthropic/models/beta_error_response.rbi +10 -2
- data/rbi/anthropic/models/cache_control_ephemeral.rbi +68 -3
- data/rbi/anthropic/models/cache_creation.rbi +45 -0
- data/rbi/anthropic/models/citation_char_location.rbi +6 -0
- data/rbi/anthropic/models/citation_content_block_location.rbi +6 -0
- data/rbi/anthropic/models/citation_page_location.rbi +6 -0
- data/rbi/anthropic/models/citation_search_result_location_param.rbi +74 -0
- data/rbi/anthropic/models/citations_delta.rbi +4 -2
- data/rbi/anthropic/models/citations_search_result_location.rbi +74 -0
- data/rbi/anthropic/models/content_block.rbi +3 -3
- data/rbi/anthropic/models/content_block_param.rbi +6 -5
- data/rbi/anthropic/models/document_block_param.rbi +7 -3
- data/rbi/anthropic/models/error_response.rbi +10 -2
- data/rbi/anthropic/models/message.rbi +11 -3
- data/rbi/anthropic/models/message_count_tokens_params.rbi +24 -50
- data/rbi/anthropic/models/message_count_tokens_tool.rbi +2 -0
- data/rbi/anthropic/models/message_create_params.rbi +24 -50
- data/rbi/anthropic/models/messages/batch_create_params.rbi +24 -50
- data/rbi/anthropic/models/model.rbi +4 -8
- data/rbi/anthropic/models/raw_content_block_start_event.rbi +6 -6
- data/rbi/anthropic/models/search_result_block_param.rbi +77 -0
- data/rbi/anthropic/models/text_block.rbi +2 -1
- data/rbi/anthropic/models/text_block_param.rbi +6 -3
- data/rbi/anthropic/models/text_citation.rbi +2 -1
- data/rbi/anthropic/models/text_citation_param.rbi +2 -1
- data/rbi/anthropic/models/tool.rbi +16 -5
- data/rbi/anthropic/models/tool_result_block_param.rbi +6 -1
- data/rbi/anthropic/models/tool_text_editor_20250429.rbi +62 -0
- data/rbi/anthropic/models/tool_text_editor_20250728.rbi +72 -0
- data/rbi/anthropic/models/tool_union.rbi +2 -0
- data/rbi/anthropic/models/usage.rbi +13 -0
- data/rbi/anthropic/models.rbi +14 -0
- data/rbi/anthropic/resources/beta/messages.rbi +45 -87
- data/rbi/anthropic/resources/messages.rbi +315 -69
- data/rbi/anthropic/streaming.rbi +5 -0
- data/sig/anthropic/errors.rbs +9 -0
- data/sig/anthropic/helpers/streaming/events.rbs +117 -0
- data/sig/anthropic/helpers/streaming/message_stream.rbs +57 -0
- data/sig/anthropic/internal/transport/base_client.rbs +1 -1
- data/sig/anthropic/internal/type/base_stream.rbs +4 -0
- data/sig/anthropic/internal/type/converter.rbs +24 -1
- data/sig/anthropic/internal/type/union.rbs +2 -2
- data/sig/anthropic/models/anthropic_beta.rbs +2 -0
- data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +1 -58
- data/sig/anthropic/models/beta/beta_bash_code_execution_output_block.rbs +23 -0
- data/sig/anthropic/models/beta/beta_bash_code_execution_output_block_param.rbs +23 -0
- data/sig/anthropic/models/beta/beta_bash_code_execution_result_block.rbs +44 -0
- data/sig/anthropic/models/beta/beta_bash_code_execution_result_block_param.rbs +44 -0
- data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_block.rbs +44 -0
- data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_block_param.rbs +49 -0
- data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_error.rbs +48 -0
- data/sig/anthropic/models/beta/beta_bash_code_execution_tool_result_error_param.rbs +48 -0
- data/sig/anthropic/models/beta/beta_citation_char_location.rbs +5 -0
- data/sig/anthropic/models/beta/beta_citation_config.rbs +17 -0
- data/sig/anthropic/models/beta/beta_citation_content_block_location.rbs +5 -0
- data/sig/anthropic/models/beta/beta_citation_page_location.rbs +5 -0
- data/sig/anthropic/models/beta/beta_citation_search_result_location.rbs +54 -0
- data/sig/anthropic/models/beta/beta_citation_search_result_location_param.rbs +54 -0
- data/sig/anthropic/models/beta/beta_citations_delta.rbs +1 -0
- data/sig/anthropic/models/beta/beta_code_execution_tool_20250825.rbs +34 -0
- data/sig/anthropic/models/beta/beta_content_block.rbs +5 -2
- data/sig/anthropic/models/beta/beta_content_block_param.rbs +12 -8
- data/sig/anthropic/models/beta/beta_document_block.rbs +49 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +5 -2
- data/sig/anthropic/models/beta/beta_request_document_block.rbs +62 -0
- data/sig/anthropic/models/beta/beta_search_result_block_param.rbs +53 -0
- data/sig/anthropic/models/beta/beta_server_tool_usage.rbs +12 -3
- data/sig/anthropic/models/beta/beta_server_tool_use_block.rbs +9 -1
- data/sig/anthropic/models/beta/beta_server_tool_use_block_param.rbs +9 -1
- data/sig/anthropic/models/beta/beta_text_citation.rbs +1 -0
- data/sig/anthropic/models/beta/beta_text_citation_param.rbs +1 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_create_result_block.rbs +29 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_create_result_block_param.rbs +29 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block.rbs +49 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_str_replace_result_block_param.rbs +49 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block.rbs +46 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_block_param.rbs +51 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error.rbs +53 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_tool_result_error_param.rbs +53 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_view_result_block.rbs +61 -0
- data/sig/anthropic/models/beta/beta_text_editor_code_execution_view_result_block_param.rbs +61 -0
- data/sig/anthropic/models/beta/beta_tool.rbs +14 -3
- data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +2 -0
- data/sig/anthropic/models/beta/beta_tool_text_editor_20250728.rbs +39 -0
- data/sig/anthropic/models/beta/beta_tool_union.rbs +7 -4
- data/sig/anthropic/models/beta/beta_web_fetch_block.rbs +39 -0
- data/sig/anthropic/models/beta/beta_web_fetch_block_param.rbs +39 -0
- data/sig/anthropic/models/beta/beta_web_fetch_tool_20250910.rbs +59 -0
- data/sig/anthropic/models/beta/beta_web_fetch_tool_result_block.rbs +44 -0
- data/sig/anthropic/models/beta/beta_web_fetch_tool_result_block_param.rbs +49 -0
- data/sig/anthropic/models/beta/beta_web_fetch_tool_result_error_block.rbs +29 -0
- data/sig/anthropic/models/beta/beta_web_fetch_tool_result_error_block_param.rbs +29 -0
- data/sig/anthropic/models/beta/beta_web_fetch_tool_result_error_code.rbs +32 -0
- data/sig/anthropic/models/beta/message_count_tokens_params.rbs +7 -4
- data/sig/anthropic/models/beta_error_response.rbs +13 -2
- data/sig/anthropic/models/cache_control_ephemeral.rbs +27 -3
- data/sig/anthropic/models/cache_creation.rbs +25 -0
- data/sig/anthropic/models/citation_char_location.rbs +5 -0
- data/sig/anthropic/models/citation_content_block_location.rbs +5 -0
- data/sig/anthropic/models/citation_page_location.rbs +5 -0
- data/sig/anthropic/models/citation_search_result_location_param.rbs +50 -0
- data/sig/anthropic/models/citations_delta.rbs +1 -0
- data/sig/anthropic/models/citations_search_result_location.rbs +50 -0
- data/sig/anthropic/models/content_block.rbs +2 -2
- data/sig/anthropic/models/content_block_param.rbs +6 -5
- data/sig/anthropic/models/document_block_param.rbs +4 -8
- data/sig/anthropic/models/error_response.rbs +13 -2
- data/sig/anthropic/models/message_count_tokens_tool.rbs +2 -0
- data/sig/anthropic/models/model.rbs +4 -10
- data/sig/anthropic/models/raw_content_block_start_event.rbs +2 -2
- data/sig/anthropic/models/search_result_block_param.rbs +49 -0
- data/sig/anthropic/models/text_citation.rbs +1 -0
- data/sig/anthropic/models/text_citation_param.rbs +1 -0
- data/sig/anthropic/models/tool.rbs +14 -3
- data/sig/anthropic/models/tool_result_block_param.rbs +5 -1
- data/sig/anthropic/models/tool_text_editor_20250429.rbs +30 -0
- data/sig/anthropic/models/tool_text_editor_20250728.rbs +35 -0
- data/sig/anthropic/models/tool_union.rbs +2 -0
- data/sig/anthropic/models/usage.rbs +5 -0
- data/sig/anthropic/models.rbs +12 -0
- data/sig/anthropic/streaming.rbs +3 -0
- metadata +152 -3
@@ -64,12 +64,14 @@ module Anthropic
|
|
64
64
|
# @param url [URI::Generic]
|
65
65
|
# @param status [Integer]
|
66
66
|
# @param response [Net::HTTPResponse]
|
67
|
+
# @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc]
|
67
68
|
# @param stream [Enumerable<Object>]
|
68
|
-
def initialize(model:, url:, status:, response:, stream:)
|
69
|
+
def initialize(model:, url:, status:, response:, unwrap:, stream:)
|
69
70
|
@model = model
|
70
71
|
@url = url
|
71
72
|
@status = status
|
72
73
|
@response = response
|
74
|
+
@unwrap = unwrap
|
73
75
|
@stream = stream
|
74
76
|
@iterator = iterator
|
75
77
|
|
@@ -31,14 +31,20 @@ module Anthropic
|
|
31
31
|
class << self
|
32
32
|
# @api private
|
33
33
|
#
|
34
|
+
# Coerce value to Boolean if possible, otherwise return the original value.
|
35
|
+
#
|
34
36
|
# @param value [Boolean, Object]
|
35
37
|
#
|
36
38
|
# @param state [Hash{Symbol=>Object}] .
|
37
39
|
#
|
38
|
-
# @option state [Boolean
|
40
|
+
# @option state [Boolean] :translate_names
|
41
|
+
#
|
42
|
+
# @option state [Boolean] :strictness
|
39
43
|
#
|
40
44
|
# @option state [Hash{Symbol=>Object}] :exactness
|
41
45
|
#
|
46
|
+
# @option state [Class<StandardError>] :error
|
47
|
+
#
|
42
48
|
# @option state [Integer] :branched
|
43
49
|
#
|
44
50
|
# @return [Boolean, Object]
|
@@ -15,10 +15,14 @@ module Anthropic
|
|
15
15
|
#
|
16
16
|
# @param state [Hash{Symbol=>Object}] .
|
17
17
|
#
|
18
|
-
# @option state [Boolean
|
18
|
+
# @option state [Boolean] :translate_names
|
19
|
+
#
|
20
|
+
# @option state [Boolean] :strictness
|
19
21
|
#
|
20
22
|
# @option state [Hash{Symbol=>Object}] :exactness
|
21
23
|
#
|
24
|
+
# @option state [Class<StandardError>] :error
|
25
|
+
#
|
22
26
|
# @option state [Integer] :branched
|
23
27
|
#
|
24
28
|
# @return [Object]
|
@@ -94,6 +98,48 @@ module Anthropic
|
|
94
98
|
end
|
95
99
|
end
|
96
100
|
|
101
|
+
# @api private
|
102
|
+
#
|
103
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Anthropic::Internal::Type::Converter, Class] .
|
104
|
+
#
|
105
|
+
# @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
106
|
+
#
|
107
|
+
# @option type_info [Proc] :enum
|
108
|
+
#
|
109
|
+
# @option type_info [Proc] :union
|
110
|
+
#
|
111
|
+
# @option type_info [Boolean] :"nil?"
|
112
|
+
#
|
113
|
+
# @param spec [Hash{Symbol=>Object}, Proc, Anthropic::Internal::Type::Converter, Class] .
|
114
|
+
#
|
115
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
116
|
+
#
|
117
|
+
# @option spec [Proc] :enum
|
118
|
+
#
|
119
|
+
# @option spec [Proc] :union
|
120
|
+
#
|
121
|
+
# @option spec [Boolean] :"nil?"
|
122
|
+
#
|
123
|
+
# @return [Hash{Symbol=>Object}]
|
124
|
+
def meta_info(type_info, spec)
|
125
|
+
[spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?)
|
126
|
+
end
|
127
|
+
|
128
|
+
# @api private
|
129
|
+
#
|
130
|
+
# @param translate_names [Boolean]
|
131
|
+
#
|
132
|
+
# @return [Hash{Symbol=>Object}]
|
133
|
+
def new_coerce_state(translate_names: true)
|
134
|
+
{
|
135
|
+
translate_names: translate_names,
|
136
|
+
strictness: true,
|
137
|
+
exactness: {yes: 0, no: 0, maybe: 0},
|
138
|
+
error: nil,
|
139
|
+
branched: 0
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
97
143
|
# @api private
|
98
144
|
#
|
99
145
|
# Based on `target`, transform `value` into `target`, to the extent possible:
|
@@ -110,14 +156,11 @@ module Anthropic
|
|
110
156
|
#
|
111
157
|
# @param value [Object]
|
112
158
|
#
|
113
|
-
# @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false
|
114
|
-
#
|
115
|
-
# targets:
|
159
|
+
# @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`. This informs the coercion strategy
|
160
|
+
# when we have to decide between multiple possible conversion targets:
|
116
161
|
#
|
117
162
|
# - `true`: the conversion must be exact, with minimum coercion.
|
118
163
|
# - `false`: the conversion can be approximate, with some coercion.
|
119
|
-
# - `:strong`: the conversion must be exact, with no coercion, and raise an error
|
120
|
-
# if not possible.
|
121
164
|
#
|
122
165
|
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
|
123
166
|
# any given conversion attempt, the exactness will be updated based on how closely
|
@@ -130,21 +173,20 @@ module Anthropic
|
|
130
173
|
#
|
131
174
|
# See implementation below for more details.
|
132
175
|
#
|
133
|
-
# @option state [Boolean
|
176
|
+
# @option state [Boolean] :translate_names
|
177
|
+
#
|
178
|
+
# @option state [Boolean] :strictness
|
134
179
|
#
|
135
180
|
# @option state [Hash{Symbol=>Object}] :exactness
|
136
181
|
#
|
182
|
+
# @option state [Class<StandardError>] :error
|
183
|
+
#
|
137
184
|
# @option state [Integer] :branched
|
138
185
|
#
|
139
186
|
# @return [Object]
|
140
|
-
def coerce(
|
141
|
-
target,
|
142
|
-
value,
|
143
|
-
state: {strictness: true, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0}
|
144
|
-
)
|
145
|
-
# rubocop:disable Lint/SuppressedException
|
187
|
+
def coerce(target, value, state: Anthropic::Internal::Type::Converter.new_coerce_state)
|
146
188
|
# rubocop:disable Metrics/BlockNesting
|
147
|
-
|
189
|
+
exactness = state.fetch(:exactness)
|
148
190
|
|
149
191
|
case target
|
150
192
|
in Anthropic::Internal::Type::Converter
|
@@ -160,29 +202,26 @@ module Anthropic
|
|
160
202
|
exactness[value.nil? ? :yes : :maybe] += 1
|
161
203
|
return nil
|
162
204
|
in -> { _1 <= Integer }
|
163
|
-
|
205
|
+
case value
|
206
|
+
in Integer
|
164
207
|
exactness[:yes] += 1
|
165
208
|
return value
|
166
|
-
elsif strictness == :strong && Integer(value, exception: false) != value
|
167
|
-
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
168
|
-
raise value.is_a?(Numeric) ? ArgumentError.new(message) : TypeError.new(message)
|
169
209
|
else
|
170
210
|
Kernel.then do
|
171
211
|
return Integer(value).tap { exactness[:maybe] += 1 }
|
172
|
-
rescue ArgumentError, TypeError
|
212
|
+
rescue ArgumentError, TypeError => e
|
213
|
+
state[:error] = e
|
173
214
|
end
|
174
215
|
end
|
175
216
|
in -> { _1 <= Float }
|
176
217
|
if value.is_a?(Numeric)
|
177
218
|
exactness[:yes] += 1
|
178
219
|
return Float(value)
|
179
|
-
elsif strictness == :strong
|
180
|
-
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
181
|
-
raise TypeError.new(message)
|
182
220
|
else
|
183
221
|
Kernel.then do
|
184
222
|
return Float(value).tap { exactness[:maybe] += 1 }
|
185
|
-
rescue ArgumentError, TypeError
|
223
|
+
rescue ArgumentError, TypeError => e
|
224
|
+
state[:error] = e
|
186
225
|
end
|
187
226
|
end
|
188
227
|
in -> { _1 <= String }
|
@@ -194,16 +233,13 @@ module Anthropic
|
|
194
233
|
exactness[:yes] += 1
|
195
234
|
return value.string
|
196
235
|
else
|
197
|
-
|
198
|
-
message = "no implicit conversion of #{value.class} into #{target.inspect}"
|
199
|
-
raise TypeError.new(message)
|
200
|
-
end
|
236
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{String}")
|
201
237
|
end
|
202
238
|
in -> { _1 <= Date || _1 <= Time }
|
203
239
|
Kernel.then do
|
204
240
|
return target.parse(value).tap { exactness[:yes] += 1 }
|
205
241
|
rescue ArgumentError, TypeError => e
|
206
|
-
|
242
|
+
state[:error] = e
|
207
243
|
end
|
208
244
|
in -> { _1 <= StringIO } if value.is_a?(String)
|
209
245
|
exactness[:yes] += 1
|
@@ -221,10 +257,8 @@ module Anthropic
|
|
221
257
|
return value
|
222
258
|
end
|
223
259
|
else
|
224
|
-
|
225
|
-
|
226
|
-
raise ArgumentError.new(message)
|
227
|
-
end
|
260
|
+
message = "cannot convert non-matching #{value.class} into #{target.inspect}"
|
261
|
+
state[:error] = ArgumentError.new(message)
|
228
262
|
end
|
229
263
|
else
|
230
264
|
end
|
@@ -232,7 +266,6 @@ module Anthropic
|
|
232
266
|
exactness[:no] += 1
|
233
267
|
value
|
234
268
|
# rubocop:enable Metrics/BlockNesting
|
235
|
-
# rubocop:enable Lint/SuppressedException
|
236
269
|
end
|
237
270
|
|
238
271
|
# @api private
|
@@ -277,8 +310,10 @@ module Anthropic
|
|
277
310
|
define_sorbet_constant!(:CoerceState) do
|
278
311
|
T.type_alias do
|
279
312
|
{
|
280
|
-
|
313
|
+
translate_names: T::Boolean,
|
314
|
+
strictness: T::Boolean,
|
281
315
|
exactness: {yes: Integer, no: Integer, maybe: Integer},
|
316
|
+
error: T::Class[StandardError],
|
282
317
|
branched: Integer
|
283
318
|
}
|
284
319
|
end
|
@@ -81,10 +81,14 @@ module Anthropic
|
|
81
81
|
#
|
82
82
|
# @param state [Hash{Symbol=>Object}] .
|
83
83
|
#
|
84
|
-
# @option state [Boolean
|
84
|
+
# @option state [Boolean] :translate_names
|
85
|
+
#
|
86
|
+
# @option state [Boolean] :strictness
|
85
87
|
#
|
86
88
|
# @option state [Hash{Symbol=>Object}] :exactness
|
87
89
|
#
|
90
|
+
# @option state [Class<StandardError>] :error
|
91
|
+
#
|
88
92
|
# @option state [Integer] :branched
|
89
93
|
#
|
90
94
|
# @return [Symbol, Object]
|
@@ -95,8 +99,12 @@ module Anthropic
|
|
95
99
|
if values.include?(val)
|
96
100
|
exactness[:yes] += 1
|
97
101
|
val
|
102
|
+
elsif values.first&.class == val.class
|
103
|
+
exactness[:maybe] += 1
|
104
|
+
value
|
98
105
|
else
|
99
|
-
exactness[
|
106
|
+
exactness[:no] += 1
|
107
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}")
|
100
108
|
value
|
101
109
|
end
|
102
110
|
end
|
@@ -116,11 +124,14 @@ module Anthropic
|
|
116
124
|
#
|
117
125
|
# @return [Object]
|
118
126
|
def to_sorbet_type
|
119
|
-
|
127
|
+
types = values.map { Anthropic::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
|
128
|
+
case types
|
120
129
|
in []
|
121
130
|
T.noreturn
|
122
|
-
in [
|
123
|
-
|
131
|
+
in [type]
|
132
|
+
type
|
133
|
+
else
|
134
|
+
T.any(*types)
|
124
135
|
end
|
125
136
|
end
|
126
137
|
|
@@ -45,10 +45,14 @@ module Anthropic
|
|
45
45
|
#
|
46
46
|
# @param state [Hash{Symbol=>Object}] .
|
47
47
|
#
|
48
|
-
# @option state [Boolean
|
48
|
+
# @option state [Boolean] :translate_names
|
49
|
+
#
|
50
|
+
# @option state [Boolean] :strictness
|
49
51
|
#
|
50
52
|
# @option state [Hash{Symbol=>Object}] :exactness
|
51
53
|
#
|
54
|
+
# @option state [Class<StandardError>] :error
|
55
|
+
#
|
52
56
|
# @option state [Integer] :branched
|
53
57
|
#
|
54
58
|
# @return [StringIO, Object]
|
@@ -62,6 +66,7 @@ module Anthropic
|
|
62
66
|
exactness[:yes] += 1
|
63
67
|
value
|
64
68
|
else
|
69
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{StringIO}")
|
65
70
|
exactness[:no] += 1
|
66
71
|
value
|
67
72
|
end
|
@@ -77,10 +77,14 @@ module Anthropic
|
|
77
77
|
#
|
78
78
|
# @param state [Hash{Symbol=>Object}] .
|
79
79
|
#
|
80
|
-
# @option state [Boolean
|
80
|
+
# @option state [Boolean] :translate_names
|
81
|
+
#
|
82
|
+
# @option state [Boolean] :strictness
|
81
83
|
#
|
82
84
|
# @option state [Hash{Symbol=>Object}] :exactness
|
83
85
|
#
|
86
|
+
# @option state [Class<StandardError>] :error
|
87
|
+
#
|
84
88
|
# @option state [Integer] :branched
|
85
89
|
#
|
86
90
|
# @return [Hash{Symbol=>Object}, Object]
|
@@ -89,6 +93,7 @@ module Anthropic
|
|
89
93
|
|
90
94
|
unless value.is_a?(Hash)
|
91
95
|
exactness[:no] += 1
|
96
|
+
state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}")
|
92
97
|
return value
|
93
98
|
end
|
94
99
|
|
@@ -163,6 +168,7 @@ module Anthropic
|
|
163
168
|
# @option spec [Boolean] :"nil?"
|
164
169
|
def initialize(type_info, spec = {})
|
165
170
|
@item_type_fn = Anthropic::Internal::Type::Converter.type_info(type_info || spec)
|
171
|
+
@meta = Anthropic::Internal::Type::Converter.meta_info(type_info, spec)
|
166
172
|
@nilable = spec.fetch(:nil?, false)
|
167
173
|
end
|
168
174
|
|
@@ -37,20 +37,20 @@ module Anthropic
|
|
37
37
|
#
|
38
38
|
# All of the specified variant info for this union.
|
39
39
|
#
|
40
|
-
# @return [Array<Array(Symbol, Proc)>]
|
40
|
+
# @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
|
41
41
|
private def known_variants = (@known_variants ||= [])
|
42
42
|
|
43
43
|
# @api private
|
44
44
|
#
|
45
|
-
# @return [Array<Array(Symbol, Object)>]
|
45
|
+
# @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
|
46
46
|
protected def derefed_variants
|
47
|
-
known_variants.map { |key, variant_fn| [key, variant_fn.call] }
|
47
|
+
known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
|
48
48
|
end
|
49
49
|
|
50
50
|
# All of the specified variants for this union.
|
51
51
|
#
|
52
52
|
# @return [Array<Object>]
|
53
|
-
def variants = derefed_variants.map
|
53
|
+
def variants = derefed_variants.map { _2 }
|
54
54
|
|
55
55
|
# @api private
|
56
56
|
#
|
@@ -76,12 +76,13 @@ module Anthropic
|
|
76
76
|
#
|
77
77
|
# @option spec [Boolean] :"nil?"
|
78
78
|
private def variant(key, spec = nil)
|
79
|
+
meta = Anthropic::Internal::Type::Converter.meta_info(nil, spec)
|
79
80
|
variant_info =
|
80
81
|
case key
|
81
82
|
in Symbol
|
82
|
-
[key, Anthropic::Internal::Type::Converter.type_info(spec)]
|
83
|
+
[key, Anthropic::Internal::Type::Converter.type_info(spec), meta]
|
83
84
|
in Proc | Anthropic::Internal::Type::Converter | Class | Hash
|
84
|
-
[nil, Anthropic::Internal::Type::Converter.type_info(key)]
|
85
|
+
[nil, Anthropic::Internal::Type::Converter.type_info(key), meta]
|
85
86
|
end
|
86
87
|
|
87
88
|
known_variants << variant_info
|
@@ -104,7 +105,8 @@ module Anthropic
|
|
104
105
|
return nil if key == Anthropic::Internal::OMIT
|
105
106
|
|
106
107
|
key = key.to_sym if key.is_a?(String)
|
107
|
-
known_variants.find { |k,| k == key }
|
108
|
+
_, found = known_variants.find { |k,| k == key }
|
109
|
+
found&.call
|
108
110
|
else
|
109
111
|
nil
|
110
112
|
end
|
@@ -140,14 +142,23 @@ module Anthropic
|
|
140
142
|
|
141
143
|
# @api private
|
142
144
|
#
|
145
|
+
# Tries to efficiently coerce the given value to one of the known variants.
|
146
|
+
#
|
147
|
+
# If the value cannot match any of the known variants, the coercion is considered
|
148
|
+
# non-viable and returns the original value.
|
149
|
+
#
|
143
150
|
# @param value [Object]
|
144
151
|
#
|
145
152
|
# @param state [Hash{Symbol=>Object}] .
|
146
153
|
#
|
147
|
-
# @option state [Boolean
|
154
|
+
# @option state [Boolean] :translate_names
|
155
|
+
#
|
156
|
+
# @option state [Boolean] :strictness
|
148
157
|
#
|
149
158
|
# @option state [Hash{Symbol=>Object}] :exactness
|
150
159
|
#
|
160
|
+
# @option state [Class<StandardError>] :error
|
161
|
+
#
|
151
162
|
# @option state [Integer] :branched
|
152
163
|
#
|
153
164
|
# @return [Object]
|
@@ -158,7 +169,6 @@ module Anthropic
|
|
158
169
|
|
159
170
|
strictness = state.fetch(:strictness)
|
160
171
|
exactness = state.fetch(:exactness)
|
161
|
-
state[:strictness] = strictness == :strong ? true : strictness
|
162
172
|
|
163
173
|
alternatives = []
|
164
174
|
known_variants.each do |_, variant_fn|
|
@@ -177,13 +187,10 @@ module Anthropic
|
|
177
187
|
end
|
178
188
|
end
|
179
189
|
|
180
|
-
case alternatives.sort_by(&:first)
|
190
|
+
case alternatives.sort_by!(&:first)
|
181
191
|
in []
|
182
192
|
exactness[:no] += 1
|
183
|
-
|
184
|
-
message = "no possible conversion of #{value.class} into a variant of #{target.inspect}"
|
185
|
-
raise ArgumentError.new(message)
|
186
|
-
end
|
193
|
+
state[:error] = ArgumentError.new("no matching variant for #{value.inspect}")
|
187
194
|
value
|
188
195
|
in [[_, exact, coerced], *]
|
189
196
|
exact.each { exactness[_1] += _2 }
|
@@ -220,11 +227,14 @@ module Anthropic
|
|
220
227
|
#
|
221
228
|
# @return [Object]
|
222
229
|
def to_sorbet_type
|
223
|
-
|
230
|
+
types = variants.map { Anthropic::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
|
231
|
+
case types
|
224
232
|
in []
|
225
233
|
T.noreturn
|
234
|
+
in [type]
|
235
|
+
type
|
226
236
|
else
|
227
|
-
T.any(*
|
237
|
+
T.any(*types)
|
228
238
|
end
|
229
239
|
end
|
230
240
|
|
@@ -33,14 +33,20 @@ module Anthropic
|
|
33
33
|
class << self
|
34
34
|
# @api private
|
35
35
|
#
|
36
|
+
# No coercion needed for Unknown type.
|
37
|
+
#
|
36
38
|
# @param value [Object]
|
37
39
|
#
|
38
40
|
# @param state [Hash{Symbol=>Object}] .
|
39
41
|
#
|
40
|
-
# @option state [Boolean
|
42
|
+
# @option state [Boolean] :translate_names
|
43
|
+
#
|
44
|
+
# @option state [Boolean] :strictness
|
41
45
|
#
|
42
46
|
# @option state [Hash{Symbol=>Object}] :exactness
|
43
47
|
#
|
48
|
+
# @option state [Class<StandardError>] :error
|
49
|
+
#
|
44
50
|
# @option state [Integer] :branched
|
45
51
|
#
|
46
52
|
# @return [Object]
|
@@ -244,7 +244,7 @@ module Anthropic
|
|
244
244
|
#
|
245
245
|
# @return [String]
|
246
246
|
def uri_origin(uri)
|
247
|
-
"#{uri.scheme}://#{uri.host}#{uri.port
|
247
|
+
"#{uri.scheme}://#{uri.host}#{":#{uri.port}" unless uri.port == uri.default_port}"
|
248
248
|
end
|
249
249
|
|
250
250
|
# @api private
|
@@ -497,7 +497,7 @@ module Anthropic
|
|
497
497
|
# @param closing [Array<Proc>]
|
498
498
|
# @param content_type [String, nil]
|
499
499
|
private def write_multipart_content(y, val:, closing:, content_type: nil)
|
500
|
-
|
500
|
+
content_line = "Content-Type: %s\r\n\r\n"
|
501
501
|
|
502
502
|
case val
|
503
503
|
in Anthropic::FilePart
|
@@ -508,24 +508,21 @@ module Anthropic
|
|
508
508
|
content_type: val.content_type
|
509
509
|
)
|
510
510
|
in Pathname
|
511
|
-
y <<
|
511
|
+
y << format(content_line, content_type || "application/octet-stream")
|
512
512
|
io = val.open(binmode: true)
|
513
513
|
closing << io.method(:close)
|
514
514
|
IO.copy_stream(io, y)
|
515
515
|
in IO
|
516
|
-
y <<
|
516
|
+
y << format(content_line, content_type || "application/octet-stream")
|
517
517
|
IO.copy_stream(val, y)
|
518
518
|
in StringIO
|
519
|
-
y <<
|
519
|
+
y << format(content_line, content_type || "application/octet-stream")
|
520
520
|
y << val.string
|
521
|
-
in String
|
522
|
-
y << "Content-Type: #{content_type}\r\n\r\n"
|
523
|
-
y << val.to_s
|
524
521
|
in -> { primitive?(_1) }
|
525
|
-
y << "
|
522
|
+
y << format(content_line, content_type || "text/plain")
|
526
523
|
y << val.to_s
|
527
524
|
else
|
528
|
-
y << "
|
525
|
+
y << format(content_line, content_type || "application/json")
|
529
526
|
y << JSON.generate(val)
|
530
527
|
end
|
531
528
|
y << "\r\n"
|
@@ -563,11 +560,13 @@ module Anthropic
|
|
563
560
|
|
564
561
|
# @api private
|
565
562
|
#
|
563
|
+
# https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content
|
564
|
+
#
|
566
565
|
# @param body [Object]
|
567
566
|
#
|
568
567
|
# @return [Array(String, Enumerable<String>)]
|
569
568
|
private def encode_multipart_streaming(body)
|
570
|
-
boundary = SecureRandom.urlsafe_base64(
|
569
|
+
boundary = SecureRandom.urlsafe_base64(30)
|
571
570
|
|
572
571
|
closing = []
|
573
572
|
strio = writable_enum do |y|
|
@@ -35,6 +35,8 @@ module Anthropic
|
|
35
35
|
|
36
36
|
variant const: -> { Anthropic::Models::AnthropicBeta::EXTENDED_CACHE_TTL_2025_04_11 }
|
37
37
|
|
38
|
+
variant const: -> { Anthropic::Models::AnthropicBeta::CONTEXT_1M_2025_08_07 }
|
39
|
+
|
38
40
|
# @!method self.variants
|
39
41
|
# @return [Array(String, Symbol)]
|
40
42
|
|
@@ -58,6 +60,7 @@ module Anthropic
|
|
58
60
|
INTERLEAVED_THINKING_2025_05_14 = :"interleaved-thinking-2025-05-14"
|
59
61
|
CODE_EXECUTION_2025_05_22 = :"code-execution-2025-05-22"
|
60
62
|
EXTENDED_CACHE_TTL_2025_04_11 = :"extended-cache-ttl-2025-04-11"
|
63
|
+
CONTEXT_1M_2025_08_07 = :"context-1m-2025-08-07"
|
61
64
|
|
62
65
|
# @!endgroup
|
63
66
|
end
|
@@ -3,71 +3,7 @@
|
|
3
3
|
module Anthropic
|
4
4
|
module Models
|
5
5
|
module Beta
|
6
|
-
|
7
|
-
# @!attribute source
|
8
|
-
#
|
9
|
-
# @return [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
|
10
|
-
required :source, union: -> { Anthropic::Beta::BetaBase64PDFBlock::Source }
|
11
|
-
|
12
|
-
# @!attribute type
|
13
|
-
#
|
14
|
-
# @return [Symbol, :document]
|
15
|
-
required :type, const: :document
|
16
|
-
|
17
|
-
# @!attribute cache_control
|
18
|
-
# Create a cache control breakpoint at this content block.
|
19
|
-
#
|
20
|
-
# @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
|
21
|
-
optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
|
22
|
-
|
23
|
-
# @!attribute citations
|
24
|
-
#
|
25
|
-
# @return [Anthropic::Models::Beta::BetaCitationsConfigParam, nil]
|
26
|
-
optional :citations, -> { Anthropic::Beta::BetaCitationsConfigParam }
|
27
|
-
|
28
|
-
# @!attribute context
|
29
|
-
#
|
30
|
-
# @return [String, nil]
|
31
|
-
optional :context, String, nil?: true
|
32
|
-
|
33
|
-
# @!attribute title
|
34
|
-
#
|
35
|
-
# @return [String, nil]
|
36
|
-
optional :title, String, nil?: true
|
37
|
-
|
38
|
-
# @!method initialize(source:, cache_control: nil, citations: nil, context: nil, title: nil, type: :document)
|
39
|
-
# @param source [Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource]
|
40
|
-
#
|
41
|
-
# @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
|
42
|
-
#
|
43
|
-
# @param citations [Anthropic::Models::Beta::BetaCitationsConfigParam]
|
44
|
-
#
|
45
|
-
# @param context [String, nil]
|
46
|
-
#
|
47
|
-
# @param title [String, nil]
|
48
|
-
#
|
49
|
-
# @param type [Symbol, :document]
|
50
|
-
|
51
|
-
# @see Anthropic::Models::Beta::BetaBase64PDFBlock#source
|
52
|
-
module Source
|
53
|
-
extend Anthropic::Internal::Type::Union
|
54
|
-
|
55
|
-
discriminator :type
|
56
|
-
|
57
|
-
variant :base64, -> { Anthropic::Beta::BetaBase64PDFSource }
|
58
|
-
|
59
|
-
variant :text, -> { Anthropic::Beta::BetaPlainTextSource }
|
60
|
-
|
61
|
-
variant :content, -> { Anthropic::Beta::BetaContentBlockSource }
|
62
|
-
|
63
|
-
variant :url, -> { Anthropic::Beta::BetaURLPDFSource }
|
64
|
-
|
65
|
-
variant :file, -> { Anthropic::Beta::BetaFileDocumentSource }
|
66
|
-
|
67
|
-
# @!method self.variants
|
68
|
-
# @return [Array(Anthropic::Models::Beta::BetaBase64PDFSource, Anthropic::Models::Beta::BetaPlainTextSource, Anthropic::Models::Beta::BetaContentBlockSource, Anthropic::Models::Beta::BetaURLPDFSource, Anthropic::Models::Beta::BetaFileDocumentSource)]
|
69
|
-
end
|
70
|
-
end
|
6
|
+
BetaBase64PDFBlock = Anthropic::Models::Beta::BetaRequestDocumentBlock
|
71
7
|
end
|
72
8
|
|
73
9
|
BetaBase64PDFBlock = Beta::BetaBase64PDFBlock
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Models
|
5
|
+
module Beta
|
6
|
+
class BetaBashCodeExecutionOutputBlock < Anthropic::Internal::Type::BaseModel
|
7
|
+
# @!attribute file_id
|
8
|
+
#
|
9
|
+
# @return [String]
|
10
|
+
required :file_id, String
|
11
|
+
|
12
|
+
# @!attribute type
|
13
|
+
#
|
14
|
+
# @return [Symbol, :bash_code_execution_output]
|
15
|
+
required :type, const: :bash_code_execution_output
|
16
|
+
|
17
|
+
# @!method initialize(file_id:, type: :bash_code_execution_output)
|
18
|
+
# @param file_id [String]
|
19
|
+
# @param type [Symbol, :bash_code_execution_output]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
BetaBashCodeExecutionOutputBlock = Beta::BetaBashCodeExecutionOutputBlock
|
24
|
+
end
|
25
|
+
end
|