anthropic-sdk-beta 0.1.0.pre.beta.3
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 +7 -0
- data/README.md +343 -0
- data/lib/anthropic/bedrock/client.rb +261 -0
- data/lib/anthropic/client.rb +107 -0
- data/lib/anthropic/errors.rb +192 -0
- data/lib/anthropic/internal/jsonl_stream.rb +26 -0
- data/lib/anthropic/internal/page.rb +109 -0
- data/lib/anthropic/internal/stream.rb +58 -0
- data/lib/anthropic/internal/transport/base_client.rb +473 -0
- data/lib/anthropic/internal/transport/pooled_net_requester.rb +193 -0
- data/lib/anthropic/internal/type/array_of.rb +128 -0
- data/lib/anthropic/internal/type/base_model.rb +380 -0
- data/lib/anthropic/internal/type/base_page.rb +46 -0
- data/lib/anthropic/internal/type/base_stream.rb +73 -0
- data/lib/anthropic/internal/type/boolean.rb +58 -0
- data/lib/anthropic/internal/type/converter.rb +247 -0
- data/lib/anthropic/internal/type/enum.rb +113 -0
- data/lib/anthropic/internal/type/hash_of.rb +148 -0
- data/lib/anthropic/internal/type/io_like.rb +75 -0
- data/lib/anthropic/internal/type/request_parameters.rb +49 -0
- data/lib/anthropic/internal/type/union.rb +216 -0
- data/lib/anthropic/internal/type/unknown.rb +62 -0
- data/lib/anthropic/internal/util.rb +755 -0
- data/lib/anthropic/internal.rb +8 -0
- data/lib/anthropic/models/anthropic_beta.rb +44 -0
- data/lib/anthropic/models/api_error_object.rb +25 -0
- data/lib/anthropic/models/authentication_error.rb +25 -0
- data/lib/anthropic/models/base64_image_source.rb +47 -0
- data/lib/anthropic/models/base64_pdf_source.rb +31 -0
- data/lib/anthropic/models/beta/beta_base64_image_source.rb +51 -0
- data/lib/anthropic/models/beta/beta_base64_pdf_block.rb +76 -0
- data/lib/anthropic/models/beta/beta_base64_pdf_source.rb +35 -0
- data/lib/anthropic/models/beta/beta_cache_control_ephemeral.rb +23 -0
- data/lib/anthropic/models/beta/beta_citation_char_location.rb +63 -0
- data/lib/anthropic/models/beta/beta_citation_char_location_param.rb +63 -0
- data/lib/anthropic/models/beta/beta_citation_content_block_location.rb +63 -0
- data/lib/anthropic/models/beta/beta_citation_content_block_location_param.rb +63 -0
- data/lib/anthropic/models/beta/beta_citation_page_location.rb +63 -0
- data/lib/anthropic/models/beta/beta_citation_page_location_param.rb +63 -0
- data/lib/anthropic/models/beta/beta_citations_config_param.rb +27 -0
- data/lib/anthropic/models/beta/beta_citations_delta.rb +46 -0
- data/lib/anthropic/models/beta/beta_content_block.rb +27 -0
- data/lib/anthropic/models/beta/beta_content_block_param.rb +33 -0
- data/lib/anthropic/models/beta/beta_content_block_source.rb +45 -0
- data/lib/anthropic/models/beta/beta_content_block_source_content.rb +23 -0
- data/lib/anthropic/models/beta/beta_image_block_param.rb +50 -0
- data/lib/anthropic/models/beta/beta_input_json_delta.rb +29 -0
- data/lib/anthropic/models/beta/beta_message.rb +143 -0
- data/lib/anthropic/models/beta/beta_message_delta_usage.rb +24 -0
- data/lib/anthropic/models/beta/beta_message_param.rb +59 -0
- data/lib/anthropic/models/beta/beta_message_tokens_count.rb +26 -0
- data/lib/anthropic/models/beta/beta_metadata.rb +28 -0
- data/lib/anthropic/models/beta/beta_model_info.rb +49 -0
- data/lib/anthropic/models/beta/beta_plain_text_source.rb +35 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_delta.rb +29 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_delta_event.rb +35 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +55 -0
- data/lib/anthropic/models/beta/beta_raw_content_block_stop_event.rb +29 -0
- data/lib/anthropic/models/beta/beta_raw_message_delta_event.rb +71 -0
- data/lib/anthropic/models/beta/beta_raw_message_start_event.rb +29 -0
- data/lib/anthropic/models/beta/beta_raw_message_stop_event.rb +23 -0
- data/lib/anthropic/models/beta/beta_raw_message_stream_event.rb +31 -0
- data/lib/anthropic/models/beta/beta_redacted_thinking_block.rb +29 -0
- data/lib/anthropic/models/beta/beta_redacted_thinking_block_param.rb +29 -0
- data/lib/anthropic/models/beta/beta_signature_delta.rb +29 -0
- data/lib/anthropic/models/beta/beta_stop_reason.rb +24 -0
- data/lib/anthropic/models/beta/beta_text_block.rb +42 -0
- data/lib/anthropic/models/beta/beta_text_block_param.rb +43 -0
- data/lib/anthropic/models/beta/beta_text_citation.rb +25 -0
- data/lib/anthropic/models/beta/beta_text_citation_param.rb +25 -0
- data/lib/anthropic/models/beta/beta_text_delta.rb +29 -0
- data/lib/anthropic/models/beta/beta_thinking_block.rb +35 -0
- data/lib/anthropic/models/beta/beta_thinking_block_param.rb +35 -0
- data/lib/anthropic/models/beta/beta_thinking_config_disabled.rb +23 -0
- data/lib/anthropic/models/beta/beta_thinking_config_enabled.rb +38 -0
- data/lib/anthropic/models/beta/beta_thinking_config_param.rb +32 -0
- data/lib/anthropic/models/beta/beta_thinking_delta.rb +29 -0
- data/lib/anthropic/models/beta/beta_tool.rb +103 -0
- data/lib/anthropic/models/beta/beta_tool_bash_20241022.rb +38 -0
- data/lib/anthropic/models/beta/beta_tool_bash_20250124.rb +38 -0
- data/lib/anthropic/models/beta/beta_tool_choice.rb +33 -0
- data/lib/anthropic/models/beta/beta_tool_choice_any.rb +39 -0
- data/lib/anthropic/models/beta/beta_tool_choice_auto.rb +39 -0
- data/lib/anthropic/models/beta/beta_tool_choice_none.rb +25 -0
- data/lib/anthropic/models/beta/beta_tool_choice_tool.rb +46 -0
- data/lib/anthropic/models/beta/beta_tool_computer_use_20241022.rb +69 -0
- data/lib/anthropic/models/beta/beta_tool_computer_use_20250124.rb +69 -0
- data/lib/anthropic/models/beta/beta_tool_result_block_param.rb +85 -0
- data/lib/anthropic/models/beta/beta_tool_text_editor_20241022.rb +38 -0
- data/lib/anthropic/models/beta/beta_tool_text_editor_20250124.rb +38 -0
- data/lib/anthropic/models/beta/beta_tool_union.rb +31 -0
- data/lib/anthropic/models/beta/beta_tool_use_block.rb +41 -0
- data/lib/anthropic/models/beta/beta_tool_use_block_param.rb +47 -0
- data/lib/anthropic/models/beta/beta_url_image_source.rb +29 -0
- data/lib/anthropic/models/beta/beta_url_pdf_source.rb +29 -0
- data/lib/anthropic/models/beta/beta_usage.rb +45 -0
- data/lib/anthropic/models/beta/message_count_tokens_params.rb +315 -0
- data/lib/anthropic/models/beta/message_create_params.rb +395 -0
- data/lib/anthropic/models/beta/messages/batch_cancel_params.rb +34 -0
- data/lib/anthropic/models/beta/messages/batch_create_params.rb +463 -0
- data/lib/anthropic/models/beta/messages/batch_delete_params.rb +34 -0
- data/lib/anthropic/models/beta/messages/batch_list_params.rb +71 -0
- data/lib/anthropic/models/beta/messages/batch_results_params.rb +34 -0
- data/lib/anthropic/models/beta/messages/batch_retrieve_params.rb +34 -0
- data/lib/anthropic/models/beta/messages/beta_deleted_message_batch.rb +34 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch.rb +140 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_canceled_result.rb +23 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_errored_result.rb +29 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_expired_result.rb +23 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_individual_response.rb +42 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_request_counts.rb +60 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_result.rb +32 -0
- data/lib/anthropic/models/beta/messages/beta_message_batch_succeeded_result.rb +29 -0
- data/lib/anthropic/models/beta/model_list_params.rb +58 -0
- data/lib/anthropic/models/beta/model_retrieve_params.rb +21 -0
- data/lib/anthropic/models/beta_api_error.rb +25 -0
- data/lib/anthropic/models/beta_authentication_error.rb +25 -0
- data/lib/anthropic/models/beta_billing_error.rb +25 -0
- data/lib/anthropic/models/beta_error.rb +33 -0
- data/lib/anthropic/models/beta_error_response.rb +25 -0
- data/lib/anthropic/models/beta_gateway_timeout_error.rb +25 -0
- data/lib/anthropic/models/beta_invalid_request_error.rb +25 -0
- data/lib/anthropic/models/beta_not_found_error.rb +25 -0
- data/lib/anthropic/models/beta_overloaded_error.rb +25 -0
- data/lib/anthropic/models/beta_permission_error.rb +25 -0
- data/lib/anthropic/models/beta_rate_limit_error.rb +25 -0
- data/lib/anthropic/models/billing_error.rb +25 -0
- data/lib/anthropic/models/cache_control_ephemeral.rb +19 -0
- data/lib/anthropic/models/citation_char_location.rb +59 -0
- data/lib/anthropic/models/citation_char_location_param.rb +59 -0
- data/lib/anthropic/models/citation_content_block_location.rb +59 -0
- data/lib/anthropic/models/citation_content_block_location_param.rb +59 -0
- data/lib/anthropic/models/citation_page_location.rb +59 -0
- data/lib/anthropic/models/citation_page_location_param.rb +59 -0
- data/lib/anthropic/models/citations_config_param.rb +23 -0
- data/lib/anthropic/models/citations_delta.rb +42 -0
- data/lib/anthropic/models/completion.rb +63 -0
- data/lib/anthropic/models/completion_create_params.rb +152 -0
- data/lib/anthropic/models/content_block.rb +23 -0
- data/lib/anthropic/models/content_block_param.rb +29 -0
- data/lib/anthropic/models/content_block_source.rb +41 -0
- data/lib/anthropic/models/content_block_source_content.rb +19 -0
- data/lib/anthropic/models/document_block_param.rb +72 -0
- data/lib/anthropic/models/error_object.rb +33 -0
- data/lib/anthropic/models/error_response.rb +25 -0
- data/lib/anthropic/models/gateway_timeout_error.rb +25 -0
- data/lib/anthropic/models/image_block_param.rb +46 -0
- data/lib/anthropic/models/input_json_delta.rb +25 -0
- data/lib/anthropic/models/invalid_request_error.rb +25 -0
- data/lib/anthropic/models/message.rb +138 -0
- data/lib/anthropic/models/message_count_tokens_params.rb +265 -0
- data/lib/anthropic/models/message_count_tokens_tool.rb +19 -0
- data/lib/anthropic/models/message_create_params.rb +380 -0
- data/lib/anthropic/models/message_delta_usage.rb +20 -0
- data/lib/anthropic/models/message_param.rb +55 -0
- data/lib/anthropic/models/message_tokens_count.rb +22 -0
- data/lib/anthropic/models/messages/batch_cancel_params.rb +21 -0
- data/lib/anthropic/models/messages/batch_create_params.rb +449 -0
- data/lib/anthropic/models/messages/batch_delete_params.rb +21 -0
- data/lib/anthropic/models/messages/batch_list_params.rb +58 -0
- data/lib/anthropic/models/messages/batch_results_params.rb +21 -0
- data/lib/anthropic/models/messages/batch_retrieve_params.rb +21 -0
- data/lib/anthropic/models/messages/deleted_message_batch.rb +32 -0
- data/lib/anthropic/models/messages/message_batch.rb +139 -0
- data/lib/anthropic/models/messages/message_batch_canceled_result.rb +23 -0
- data/lib/anthropic/models/messages/message_batch_errored_result.rb +29 -0
- data/lib/anthropic/models/messages/message_batch_expired_result.rb +23 -0
- data/lib/anthropic/models/messages/message_batch_individual_response.rb +42 -0
- data/lib/anthropic/models/messages/message_batch_request_counts.rb +60 -0
- data/lib/anthropic/models/messages/message_batch_result.rb +32 -0
- data/lib/anthropic/models/messages/message_batch_succeeded_result.rb +29 -0
- data/lib/anthropic/models/metadata.rb +24 -0
- data/lib/anthropic/models/model.rb +93 -0
- data/lib/anthropic/models/model_info.rb +45 -0
- data/lib/anthropic/models/model_list_params.rb +56 -0
- data/lib/anthropic/models/model_retrieve_params.rb +19 -0
- data/lib/anthropic/models/not_found_error.rb +25 -0
- data/lib/anthropic/models/overloaded_error.rb +25 -0
- data/lib/anthropic/models/permission_error.rb +25 -0
- data/lib/anthropic/models/plain_text_source.rb +31 -0
- data/lib/anthropic/models/rate_limit_error.rb +25 -0
- data/lib/anthropic/models/raw_content_block_delta.rb +25 -0
- data/lib/anthropic/models/raw_content_block_delta_event.rb +31 -0
- data/lib/anthropic/models/raw_content_block_start_event.rb +50 -0
- data/lib/anthropic/models/raw_content_block_stop_event.rb +25 -0
- data/lib/anthropic/models/raw_message_delta_event.rb +67 -0
- data/lib/anthropic/models/raw_message_start_event.rb +25 -0
- data/lib/anthropic/models/raw_message_stop_event.rb +19 -0
- data/lib/anthropic/models/raw_message_stream_event.rb +27 -0
- data/lib/anthropic/models/redacted_thinking_block.rb +25 -0
- data/lib/anthropic/models/redacted_thinking_block_param.rb +25 -0
- data/lib/anthropic/models/signature_delta.rb +25 -0
- data/lib/anthropic/models/stop_reason.rb +20 -0
- data/lib/anthropic/models/text_block.rb +38 -0
- data/lib/anthropic/models/text_block_param.rb +39 -0
- data/lib/anthropic/models/text_citation.rb +21 -0
- data/lib/anthropic/models/text_citation_param.rb +21 -0
- data/lib/anthropic/models/text_delta.rb +25 -0
- data/lib/anthropic/models/thinking_block.rb +31 -0
- data/lib/anthropic/models/thinking_block_param.rb +31 -0
- data/lib/anthropic/models/thinking_config_disabled.rb +19 -0
- data/lib/anthropic/models/thinking_config_enabled.rb +34 -0
- data/lib/anthropic/models/thinking_config_param.rb +28 -0
- data/lib/anthropic/models/thinking_delta.rb +25 -0
- data/lib/anthropic/models/tool.rb +80 -0
- data/lib/anthropic/models/tool_bash_20250124.rb +34 -0
- data/lib/anthropic/models/tool_choice.rb +29 -0
- data/lib/anthropic/models/tool_choice_any.rb +35 -0
- data/lib/anthropic/models/tool_choice_auto.rb +35 -0
- data/lib/anthropic/models/tool_choice_none.rb +21 -0
- data/lib/anthropic/models/tool_choice_tool.rb +42 -0
- data/lib/anthropic/models/tool_result_block_param.rb +81 -0
- data/lib/anthropic/models/tool_text_editor_20250124.rb +34 -0
- data/lib/anthropic/models/tool_union.rb +19 -0
- data/lib/anthropic/models/tool_use_block.rb +37 -0
- data/lib/anthropic/models/tool_use_block_param.rb +43 -0
- data/lib/anthropic/models/url_image_source.rb +25 -0
- data/lib/anthropic/models/url_pdf_source.rb +25 -0
- data/lib/anthropic/models/usage.rb +41 -0
- data/lib/anthropic/request_options.rb +75 -0
- data/lib/anthropic/resources/beta/messages/batches.rb +198 -0
- data/lib/anthropic/resources/beta/messages.rb +158 -0
- data/lib/anthropic/resources/beta/models.rb +65 -0
- data/lib/anthropic/resources/beta.rb +22 -0
- data/lib/anthropic/resources/completions.rb +100 -0
- data/lib/anthropic/resources/messages/batches.rb +179 -0
- data/lib/anthropic/resources/messages.rb +145 -0
- data/lib/anthropic/resources/models.rb +63 -0
- data/lib/anthropic/version.rb +5 -0
- data/lib/anthropic/vertex/client.rb +210 -0
- data/lib/anthropic.rb +265 -0
- data/manifest.yaml +15 -0
- data/rbi/lib/anthropic/bedrock/client.rbi +80 -0
- data/rbi/lib/anthropic/client.rbi +70 -0
- data/rbi/lib/anthropic/errors.rbi +143 -0
- data/rbi/lib/anthropic/internal/jsonl_stream.rbi +16 -0
- data/rbi/lib/anthropic/internal/page.rbi +26 -0
- data/rbi/lib/anthropic/internal/stream.rbi +16 -0
- data/rbi/lib/anthropic/internal/transport/base_client.rbi +204 -0
- data/rbi/lib/anthropic/internal/transport/pooled_net_requester.rbi +60 -0
- data/rbi/lib/anthropic/internal/type/array_of.rbi +82 -0
- data/rbi/lib/anthropic/internal/type/base_model.rbi +197 -0
- data/rbi/lib/anthropic/internal/type/base_page.rbi +36 -0
- data/rbi/lib/anthropic/internal/type/base_stream.rbi +51 -0
- data/rbi/lib/anthropic/internal/type/boolean.rbi +49 -0
- data/rbi/lib/anthropic/internal/type/converter.rbi +112 -0
- data/rbi/lib/anthropic/internal/type/enum.rbi +63 -0
- data/rbi/lib/anthropic/internal/type/hash_of.rbi +82 -0
- data/rbi/lib/anthropic/internal/type/io_like.rbi +47 -0
- data/rbi/lib/anthropic/internal/type/request_parameters.rbi +21 -0
- data/rbi/lib/anthropic/internal/type/union.rbi +68 -0
- data/rbi/lib/anthropic/internal/type/unknown.rbi +41 -0
- data/rbi/lib/anthropic/internal/util.rbi +282 -0
- data/rbi/lib/anthropic/internal.rbi +12 -0
- data/rbi/lib/anthropic/models/anthropic_beta.rbi +30 -0
- data/rbi/lib/anthropic/models/api_error_object.rbi +19 -0
- data/rbi/lib/anthropic/models/authentication_error.rbi +19 -0
- data/rbi/lib/anthropic/models/base64_image_source.rbi +46 -0
- data/rbi/lib/anthropic/models/base64_pdf_source.rbi +22 -0
- data/rbi/lib/anthropic/models/beta/beta_base64_image_source.rbi +56 -0
- data/rbi/lib/anthropic/models/beta/beta_base64_pdf_block.rbi +104 -0
- data/rbi/lib/anthropic/models/beta/beta_base64_pdf_source.rbi +26 -0
- data/rbi/lib/anthropic/models/beta/beta_cache_control_ephemeral.rbi +20 -0
- data/rbi/lib/anthropic/models/beta/beta_citation_char_location.rbi +65 -0
- data/rbi/lib/anthropic/models/beta/beta_citation_char_location_param.rbi +65 -0
- data/rbi/lib/anthropic/models/beta/beta_citation_content_block_location.rbi +63 -0
- data/rbi/lib/anthropic/models/beta/beta_citation_content_block_location_param.rbi +63 -0
- data/rbi/lib/anthropic/models/beta/beta_citation_page_location.rbi +65 -0
- data/rbi/lib/anthropic/models/beta/beta_citation_page_location_param.rbi +65 -0
- data/rbi/lib/anthropic/models/beta/beta_citations_config_param.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_citations_delta.rbi +66 -0
- data/rbi/lib/anthropic/models/beta/beta_content_block.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_content_block_param.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_content_block_source.rbi +74 -0
- data/rbi/lib/anthropic/models/beta/beta_content_block_source_content.rbi +19 -0
- data/rbi/lib/anthropic/models/beta/beta_image_block_param.rbi +68 -0
- data/rbi/lib/anthropic/models/beta/beta_input_json_delta.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_message.rbi +180 -0
- data/rbi/lib/anthropic/models/beta/beta_message_delta_usage.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_message_param.rbi +126 -0
- data/rbi/lib/anthropic/models/beta/beta_message_tokens_count.rbi +22 -0
- data/rbi/lib/anthropic/models/beta/beta_metadata.rbi +25 -0
- data/rbi/lib/anthropic/models/beta/beta_model_info.rbi +38 -0
- data/rbi/lib/anthropic/models/beta/beta_plain_text_source.rbi +26 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_content_block_delta.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_content_block_delta_event.rbi +65 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_content_block_start_event.rbi +74 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_content_block_stop_event.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_message_delta_event.rbi +96 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_message_start_event.rbi +29 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_message_stop_event.rbi +20 -0
- data/rbi/lib/anthropic/models/beta/beta_raw_message_stream_event.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_redacted_thinking_block.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_redacted_thinking_block_param.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_signature_delta.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_stop_reason.rbi +24 -0
- data/rbi/lib/anthropic/models/beta/beta_text_block.rbi +76 -0
- data/rbi/lib/anthropic/models/beta/beta_text_block_param.rbi +84 -0
- data/rbi/lib/anthropic/models/beta/beta_text_citation.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_text_citation_param.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_text_delta.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_thinking_block.rbi +26 -0
- data/rbi/lib/anthropic/models/beta/beta_thinking_block_param.rbi +26 -0
- data/rbi/lib/anthropic/models/beta/beta_thinking_config_disabled.rbi +20 -0
- data/rbi/lib/anthropic/models/beta/beta_thinking_config_enabled.rbi +32 -0
- data/rbi/lib/anthropic/models/beta/beta_thinking_config_param.rbi +30 -0
- data/rbi/lib/anthropic/models/beta/beta_thinking_delta.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_tool.rbi +112 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_bash_20241022.rbi +49 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_bash_20250124.rbi +49 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_choice.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_choice_any.rbi +31 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_choice_auto.rbi +31 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_choice_none.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_choice_tool.rbi +37 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_computer_use_20241022.rbi +77 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_computer_use_20250124.rbi +77 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_result_block_param.rbi +129 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_text_editor_20241022.rbi +49 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_text_editor_20250124.rbi +49 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_union.rbi +21 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_use_block.rbi +29 -0
- data/rbi/lib/anthropic/models/beta/beta_tool_use_block_param.rbi +60 -0
- data/rbi/lib/anthropic/models/beta/beta_url_image_source.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_url_pdf_source.rbi +23 -0
- data/rbi/lib/anthropic/models/beta/beta_usage.rbi +52 -0
- data/rbi/lib/anthropic/models/beta/message_count_tokens_params.rbi +409 -0
- data/rbi/lib/anthropic/models/beta/message_create_params.rbi +489 -0
- data/rbi/lib/anthropic/models/beta/messages/batch_cancel_params.rbi +41 -0
- data/rbi/lib/anthropic/models/beta/messages/batch_create_params.rbi +572 -0
- data/rbi/lib/anthropic/models/beta/messages/batch_delete_params.rbi +41 -0
- data/rbi/lib/anthropic/models/beta/messages/batch_list_params.rbi +72 -0
- data/rbi/lib/anthropic/models/beta/messages/batch_results_params.rbi +41 -0
- data/rbi/lib/anthropic/models/beta/messages/batch_retrieve_params.rbi +41 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_deleted_message_batch.rbi +27 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch.rbi +148 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch_canceled_result.rbi +20 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch_errored_result.rbi +29 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch_expired_result.rbi +20 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch_individual_response.rbi +68 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch_request_counts.rbi +63 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch_result.rbi +26 -0
- data/rbi/lib/anthropic/models/beta/messages/beta_message_batch_succeeded_result.rbi +29 -0
- data/rbi/lib/anthropic/models/beta/model_list_params.rbi +59 -0
- data/rbi/lib/anthropic/models/beta/model_retrieve_params.rbi +21 -0
- data/rbi/lib/anthropic/models/beta_api_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_authentication_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_billing_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_error.rbi +17 -0
- data/rbi/lib/anthropic/models/beta_error_response.rbi +68 -0
- data/rbi/lib/anthropic/models/beta_gateway_timeout_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_invalid_request_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_not_found_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_overloaded_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_permission_error.rbi +19 -0
- data/rbi/lib/anthropic/models/beta_rate_limit_error.rbi +19 -0
- data/rbi/lib/anthropic/models/billing_error.rbi +19 -0
- data/rbi/lib/anthropic/models/cache_control_ephemeral.rbi +16 -0
- data/rbi/lib/anthropic/models/citation_char_location.rbi +61 -0
- data/rbi/lib/anthropic/models/citation_char_location_param.rbi +61 -0
- data/rbi/lib/anthropic/models/citation_content_block_location.rbi +59 -0
- data/rbi/lib/anthropic/models/citation_content_block_location_param.rbi +59 -0
- data/rbi/lib/anthropic/models/citation_page_location.rbi +61 -0
- data/rbi/lib/anthropic/models/citation_page_location_param.rbi +61 -0
- data/rbi/lib/anthropic/models/citations_config_param.rbi +19 -0
- data/rbi/lib/anthropic/models/citations_delta.rbi +62 -0
- data/rbi/lib/anthropic/models/completion.rbi +65 -0
- data/rbi/lib/anthropic/models/completion_create_params.rbi +142 -0
- data/rbi/lib/anthropic/models/content_block.rbi +17 -0
- data/rbi/lib/anthropic/models/content_block_param.rbi +17 -0
- data/rbi/lib/anthropic/models/content_block_source.rbi +56 -0
- data/rbi/lib/anthropic/models/content_block_source_content.rbi +12 -0
- data/rbi/lib/anthropic/models/document_block_param.rbi +97 -0
- data/rbi/lib/anthropic/models/error_object.rbi +17 -0
- data/rbi/lib/anthropic/models/error_response.rbi +68 -0
- data/rbi/lib/anthropic/models/gateway_timeout_error.rbi +19 -0
- data/rbi/lib/anthropic/models/image_block_param.rbi +57 -0
- data/rbi/lib/anthropic/models/input_json_delta.rbi +19 -0
- data/rbi/lib/anthropic/models/invalid_request_error.rbi +19 -0
- data/rbi/lib/anthropic/models/message.rbi +176 -0
- data/rbi/lib/anthropic/models/message_count_tokens_params.rbi +363 -0
- data/rbi/lib/anthropic/models/message_count_tokens_tool.rbi +17 -0
- data/rbi/lib/anthropic/models/message_create_params.rbi +453 -0
- data/rbi/lib/anthropic/models/message_delta_usage.rbi +17 -0
- data/rbi/lib/anthropic/models/message_param.rbi +121 -0
- data/rbi/lib/anthropic/models/message_tokens_count.rbi +18 -0
- data/rbi/lib/anthropic/models/messages/batch_cancel_params.rbi +21 -0
- data/rbi/lib/anthropic/models/messages/batch_create_params.rbi +535 -0
- data/rbi/lib/anthropic/models/messages/batch_delete_params.rbi +21 -0
- data/rbi/lib/anthropic/models/messages/batch_list_params.rbi +59 -0
- data/rbi/lib/anthropic/models/messages/batch_results_params.rbi +21 -0
- data/rbi/lib/anthropic/models/messages/batch_retrieve_params.rbi +21 -0
- data/rbi/lib/anthropic/models/messages/deleted_message_batch.rbi +25 -0
- data/rbi/lib/anthropic/models/messages/message_batch.rbi +143 -0
- data/rbi/lib/anthropic/models/messages/message_batch_canceled_result.rbi +20 -0
- data/rbi/lib/anthropic/models/messages/message_batch_errored_result.rbi +29 -0
- data/rbi/lib/anthropic/models/messages/message_batch_expired_result.rbi +20 -0
- data/rbi/lib/anthropic/models/messages/message_batch_individual_response.rbi +68 -0
- data/rbi/lib/anthropic/models/messages/message_batch_request_counts.rbi +63 -0
- data/rbi/lib/anthropic/models/messages/message_batch_result.rbi +26 -0
- data/rbi/lib/anthropic/models/messages/message_batch_succeeded_result.rbi +29 -0
- data/rbi/lib/anthropic/models/metadata.rbi +21 -0
- data/rbi/lib/anthropic/models/model.rbi +54 -0
- data/rbi/lib/anthropic/models/model_info.rbi +34 -0
- data/rbi/lib/anthropic/models/model_list_params.rbi +57 -0
- data/rbi/lib/anthropic/models/model_retrieve_params.rbi +19 -0
- data/rbi/lib/anthropic/models/not_found_error.rbi +19 -0
- data/rbi/lib/anthropic/models/overloaded_error.rbi +19 -0
- data/rbi/lib/anthropic/models/permission_error.rbi +19 -0
- data/rbi/lib/anthropic/models/plain_text_source.rbi +22 -0
- data/rbi/lib/anthropic/models/rate_limit_error.rbi +19 -0
- data/rbi/lib/anthropic/models/raw_content_block_delta.rbi +17 -0
- data/rbi/lib/anthropic/models/raw_content_block_delta_event.rbi +61 -0
- data/rbi/lib/anthropic/models/raw_content_block_start_event.rbi +70 -0
- data/rbi/lib/anthropic/models/raw_content_block_stop_event.rbi +19 -0
- data/rbi/lib/anthropic/models/raw_message_delta_event.rbi +81 -0
- data/rbi/lib/anthropic/models/raw_message_start_event.rbi +25 -0
- data/rbi/lib/anthropic/models/raw_message_stop_event.rbi +16 -0
- data/rbi/lib/anthropic/models/raw_message_stream_event.rbi +17 -0
- data/rbi/lib/anthropic/models/redacted_thinking_block.rbi +19 -0
- data/rbi/lib/anthropic/models/redacted_thinking_block_param.rbi +19 -0
- data/rbi/lib/anthropic/models/signature_delta.rbi +19 -0
- data/rbi/lib/anthropic/models/stop_reason.rbi +20 -0
- data/rbi/lib/anthropic/models/text_block.rbi +72 -0
- data/rbi/lib/anthropic/models/text_block_param.rbi +80 -0
- data/rbi/lib/anthropic/models/text_citation.rbi +17 -0
- data/rbi/lib/anthropic/models/text_citation_param.rbi +17 -0
- data/rbi/lib/anthropic/models/text_delta.rbi +19 -0
- data/rbi/lib/anthropic/models/thinking_block.rbi +22 -0
- data/rbi/lib/anthropic/models/thinking_block_param.rbi +22 -0
- data/rbi/lib/anthropic/models/thinking_config_disabled.rbi +16 -0
- data/rbi/lib/anthropic/models/thinking_config_enabled.rbi +28 -0
- data/rbi/lib/anthropic/models/thinking_config_param.rbi +21 -0
- data/rbi/lib/anthropic/models/thinking_delta.rbi +19 -0
- data/rbi/lib/anthropic/models/tool.rbi +88 -0
- data/rbi/lib/anthropic/models/tool_bash_20250124.rbi +43 -0
- data/rbi/lib/anthropic/models/tool_choice.rbi +19 -0
- data/rbi/lib/anthropic/models/tool_choice_any.rbi +27 -0
- data/rbi/lib/anthropic/models/tool_choice_auto.rbi +27 -0
- data/rbi/lib/anthropic/models/tool_choice_none.rbi +17 -0
- data/rbi/lib/anthropic/models/tool_choice_tool.rbi +33 -0
- data/rbi/lib/anthropic/models/tool_result_block_param.rbi +102 -0
- data/rbi/lib/anthropic/models/tool_text_editor_20250124.rbi +43 -0
- data/rbi/lib/anthropic/models/tool_union.rbi +17 -0
- data/rbi/lib/anthropic/models/tool_use_block.rbi +25 -0
- data/rbi/lib/anthropic/models/tool_use_block_param.rbi +56 -0
- data/rbi/lib/anthropic/models/url_image_source.rbi +19 -0
- data/rbi/lib/anthropic/models/url_pdf_source.rbi +19 -0
- data/rbi/lib/anthropic/models/usage.rbi +47 -0
- data/rbi/lib/anthropic/request_options.rbi +46 -0
- data/rbi/lib/anthropic/resources/beta/messages/batches.rbi +164 -0
- data/rbi/lib/anthropic/resources/beta/messages.rbi +823 -0
- data/rbi/lib/anthropic/resources/beta/models.rbi +55 -0
- data/rbi/lib/anthropic/resources/beta.rbi +17 -0
- data/rbi/lib/anthropic/resources/completions.rbi +190 -0
- data/rbi/lib/anthropic/resources/messages/batches.rbi +142 -0
- data/rbi/lib/anthropic/resources/messages.rbi +800 -0
- data/rbi/lib/anthropic/resources/models.rbi +53 -0
- data/rbi/lib/anthropic/version.rbi +5 -0
- data/rbi/lib/anthropic/vertex/client.rbi +56 -0
- data/sig/anthropic/bedrock/client.rbs +41 -0
- data/sig/anthropic/client.rbs +39 -0
- data/sig/anthropic/errors.rbs +101 -0
- data/sig/anthropic/internal/jsonl_stream.rbs +9 -0
- data/sig/anthropic/internal/page.rbs +17 -0
- data/sig/anthropic/internal/stream.rbs +9 -0
- data/sig/anthropic/internal/transport/base_client.rbs +110 -0
- data/sig/anthropic/internal/transport/pooled_net_requester.rbs +41 -0
- data/sig/anthropic/internal/type/array_of.rbs +41 -0
- data/sig/anthropic/internal/type/base_model.rbs +82 -0
- data/sig/anthropic/internal/type/base_page.rbs +24 -0
- data/sig/anthropic/internal/type/base_stream.rbs +31 -0
- data/sig/anthropic/internal/type/boolean.rbs +23 -0
- data/sig/anthropic/internal/type/converter.rbs +50 -0
- data/sig/anthropic/internal/type/enum.rbs +27 -0
- data/sig/anthropic/internal/type/hash_of.rbs +41 -0
- data/sig/anthropic/internal/type/io_like.rbs +23 -0
- data/sig/anthropic/internal/type/request_parameters.rbs +15 -0
- data/sig/anthropic/internal/type/union.rbs +45 -0
- data/sig/anthropic/internal/type/unknown.rbs +23 -0
- data/sig/anthropic/internal/util.rbs +154 -0
- data/sig/anthropic/internal.rbs +5 -0
- data/sig/anthropic/models/anthropic_beta.rbs +36 -0
- data/sig/anthropic/models/api_error_object.rbs +15 -0
- data/sig/anthropic/models/authentication_error.rbs +15 -0
- data/sig/anthropic/models/base64_image_source.rbs +40 -0
- data/sig/anthropic/models/base64_pdf_source.rbs +22 -0
- data/sig/anthropic/models/beta/beta_base64_image_source.rbs +44 -0
- data/sig/anthropic/models/beta/beta_base64_pdf_block.rbs +58 -0
- data/sig/anthropic/models/beta/beta_base64_pdf_source.rbs +26 -0
- data/sig/anthropic/models/beta/beta_cache_control_ephemeral.rbs +17 -0
- data/sig/anthropic/models/beta/beta_citation_char_location.rbs +42 -0
- data/sig/anthropic/models/beta/beta_citation_char_location_param.rbs +42 -0
- data/sig/anthropic/models/beta/beta_citation_content_block_location.rbs +42 -0
- data/sig/anthropic/models/beta/beta_citation_content_block_location_param.rbs +42 -0
- data/sig/anthropic/models/beta/beta_citation_page_location.rbs +42 -0
- data/sig/anthropic/models/beta/beta_citation_page_location_param.rbs +42 -0
- data/sig/anthropic/models/beta/beta_citations_config_param.rbs +19 -0
- data/sig/anthropic/models/beta/beta_citations_delta.rbs +37 -0
- data/sig/anthropic/models/beta/beta_content_block.rbs +19 -0
- data/sig/anthropic/models/beta/beta_content_block_param.rbs +22 -0
- data/sig/anthropic/models/beta/beta_content_block_source.rbs +41 -0
- data/sig/anthropic/models/beta/beta_content_block_source_content.rbs +17 -0
- data/sig/anthropic/models/beta/beta_image_block_param.rbs +40 -0
- data/sig/anthropic/models/beta/beta_input_json_delta.rbs +20 -0
- data/sig/anthropic/models/beta/beta_message.rbs +50 -0
- data/sig/anthropic/models/beta/beta_message_delta_usage.rbs +17 -0
- data/sig/anthropic/models/beta/beta_message_param.rbs +51 -0
- data/sig/anthropic/models/beta/beta_message_tokens_count.rbs +17 -0
- data/sig/anthropic/models/beta/beta_metadata.rbs +17 -0
- data/sig/anthropic/models/beta/beta_model_info.rbs +29 -0
- data/sig/anthropic/models/beta/beta_plain_text_source.rbs +26 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_delta.rbs +20 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_delta_event.rbs +30 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_start_event.rbs +42 -0
- data/sig/anthropic/models/beta/beta_raw_content_block_stop_event.rbs +20 -0
- data/sig/anthropic/models/beta/beta_raw_message_delta_event.rbs +49 -0
- data/sig/anthropic/models/beta/beta_raw_message_start_event.rbs +23 -0
- data/sig/anthropic/models/beta/beta_raw_message_stop_event.rbs +17 -0
- data/sig/anthropic/models/beta/beta_raw_message_stream_event.rbs +21 -0
- data/sig/anthropic/models/beta/beta_redacted_thinking_block.rbs +20 -0
- data/sig/anthropic/models/beta/beta_redacted_thinking_block_param.rbs +20 -0
- data/sig/anthropic/models/beta/beta_signature_delta.rbs +19 -0
- data/sig/anthropic/models/beta/beta_stop_reason.rbs +21 -0
- data/sig/anthropic/models/beta/beta_text_block.rbs +30 -0
- data/sig/anthropic/models/beta/beta_text_block_param.rbs +34 -0
- data/sig/anthropic/models/beta/beta_text_citation.rbs +18 -0
- data/sig/anthropic/models/beta/beta_text_citation_param.rbs +18 -0
- data/sig/anthropic/models/beta/beta_text_delta.rbs +19 -0
- data/sig/anthropic/models/beta/beta_thinking_block.rbs +26 -0
- data/sig/anthropic/models/beta/beta_thinking_block_param.rbs +26 -0
- data/sig/anthropic/models/beta/beta_thinking_config_disabled.rbs +17 -0
- data/sig/anthropic/models/beta/beta_thinking_config_enabled.rbs +20 -0
- data/sig/anthropic/models/beta/beta_thinking_config_param.rbs +17 -0
- data/sig/anthropic/models/beta/beta_thinking_delta.rbs +19 -0
- data/sig/anthropic/models/beta/beta_tool.rbs +62 -0
- data/sig/anthropic/models/beta/beta_tool_bash_20241022.rbs +30 -0
- data/sig/anthropic/models/beta/beta_tool_bash_20250124.rbs +30 -0
- data/sig/anthropic/models/beta/beta_tool_choice.rbs +19 -0
- data/sig/anthropic/models/beta/beta_tool_choice_any.rbs +22 -0
- data/sig/anthropic/models/beta/beta_tool_choice_auto.rbs +22 -0
- data/sig/anthropic/models/beta/beta_tool_choice_none.rbs +17 -0
- data/sig/anthropic/models/beta/beta_tool_choice_tool.rbs +28 -0
- data/sig/anthropic/models/beta/beta_tool_computer_use_20241022.rbs +42 -0
- data/sig/anthropic/models/beta/beta_tool_computer_use_20250124.rbs +42 -0
- data/sig/anthropic/models/beta/beta_tool_result_block_param.rbs +69 -0
- data/sig/anthropic/models/beta/beta_tool_text_editor_20241022.rbs +30 -0
- data/sig/anthropic/models/beta/beta_tool_text_editor_20250124.rbs +30 -0
- data/sig/anthropic/models/beta/beta_tool_union.rbs +22 -0
- data/sig/anthropic/models/beta/beta_tool_use_block.rbs +29 -0
- data/sig/anthropic/models/beta/beta_tool_use_block_param.rbs +38 -0
- data/sig/anthropic/models/beta/beta_url_image_source.rbs +19 -0
- data/sig/anthropic/models/beta/beta_url_pdf_source.rbs +19 -0
- data/sig/anthropic/models/beta/beta_usage.rbs +34 -0
- data/sig/anthropic/models/beta/message_count_tokens_params.rbs +98 -0
- data/sig/anthropic/models/beta/message_create_params.rbs +119 -0
- data/sig/anthropic/models/beta/messages/batch_cancel_params.rbs +29 -0
- data/sig/anthropic/models/beta/messages/batch_create_params.rbs +161 -0
- data/sig/anthropic/models/beta/messages/batch_delete_params.rbs +29 -0
- data/sig/anthropic/models/beta/messages/batch_list_params.rbs +49 -0
- data/sig/anthropic/models/beta/messages/batch_results_params.rbs +29 -0
- data/sig/anthropic/models/beta/messages/batch_retrieve_params.rbs +29 -0
- data/sig/anthropic/models/beta/messages/beta_deleted_message_batch.rbs +20 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch.rbs +70 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_canceled_result.rbs +17 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_errored_result.rbs +23 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_expired_result.rbs +17 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_individual_response.rbs +26 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_request_counts.rbs +38 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_result.rbs +19 -0
- data/sig/anthropic/models/beta/messages/beta_message_batch_succeeded_result.rbs +23 -0
- data/sig/anthropic/models/beta/model_list_params.rbs +35 -0
- data/sig/anthropic/models/beta/model_retrieve_params.rbs +17 -0
- data/sig/anthropic/models/beta_api_error.rbs +15 -0
- data/sig/anthropic/models/beta_authentication_error.rbs +16 -0
- data/sig/anthropic/models/beta_billing_error.rbs +15 -0
- data/sig/anthropic/models/beta_error.rbs +20 -0
- data/sig/anthropic/models/beta_error_response.rbs +19 -0
- data/sig/anthropic/models/beta_gateway_timeout_error.rbs +15 -0
- data/sig/anthropic/models/beta_invalid_request_error.rbs +16 -0
- data/sig/anthropic/models/beta_not_found_error.rbs +15 -0
- data/sig/anthropic/models/beta_overloaded_error.rbs +15 -0
- data/sig/anthropic/models/beta_permission_error.rbs +15 -0
- data/sig/anthropic/models/beta_rate_limit_error.rbs +15 -0
- data/sig/anthropic/models/billing_error.rbs +15 -0
- data/sig/anthropic/models/cache_control_ephemeral.rbs +13 -0
- data/sig/anthropic/models/citation_char_location.rbs +38 -0
- data/sig/anthropic/models/citation_char_location_param.rbs +38 -0
- data/sig/anthropic/models/citation_content_block_location.rbs +38 -0
- data/sig/anthropic/models/citation_content_block_location_param.rbs +38 -0
- data/sig/anthropic/models/citation_page_location.rbs +38 -0
- data/sig/anthropic/models/citation_page_location_param.rbs +38 -0
- data/sig/anthropic/models/citations_config_param.rbs +15 -0
- data/sig/anthropic/models/citations_delta.rbs +33 -0
- data/sig/anthropic/models/completion.rbs +34 -0
- data/sig/anthropic/models/completion_create_params.rbs +63 -0
- data/sig/anthropic/models/content_block.rbs +15 -0
- data/sig/anthropic/models/content_block_param.rbs +18 -0
- data/sig/anthropic/models/content_block_source.rbs +36 -0
- data/sig/anthropic/models/content_block_source_content.rbs +12 -0
- data/sig/anthropic/models/document_block_param.rbs +54 -0
- data/sig/anthropic/models/error_object.rbs +20 -0
- data/sig/anthropic/models/error_response.rbs +19 -0
- data/sig/anthropic/models/gateway_timeout_error.rbs +15 -0
- data/sig/anthropic/models/image_block_param.rbs +35 -0
- data/sig/anthropic/models/input_json_delta.rbs +15 -0
- data/sig/anthropic/models/invalid_request_error.rbs +16 -0
- data/sig/anthropic/models/message.rbs +46 -0
- data/sig/anthropic/models/message_count_tokens_params.rbs +71 -0
- data/sig/anthropic/models/message_count_tokens_tool.rbs +14 -0
- data/sig/anthropic/models/message_create_params.rbs +107 -0
- data/sig/anthropic/models/message_delta_usage.rbs +13 -0
- data/sig/anthropic/models/message_param.rbs +46 -0
- data/sig/anthropic/models/message_tokens_count.rbs +13 -0
- data/sig/anthropic/models/messages/batch_cancel_params.rbs +17 -0
- data/sig/anthropic/models/messages/batch_create_params.rbs +150 -0
- data/sig/anthropic/models/messages/batch_delete_params.rbs +17 -0
- data/sig/anthropic/models/messages/batch_list_params.rbs +35 -0
- data/sig/anthropic/models/messages/batch_results_params.rbs +17 -0
- data/sig/anthropic/models/messages/batch_retrieve_params.rbs +17 -0
- data/sig/anthropic/models/messages/deleted_message_batch.rbs +17 -0
- data/sig/anthropic/models/messages/message_batch.rbs +70 -0
- data/sig/anthropic/models/messages/message_batch_canceled_result.rbs +17 -0
- data/sig/anthropic/models/messages/message_batch_errored_result.rbs +23 -0
- data/sig/anthropic/models/messages/message_batch_expired_result.rbs +17 -0
- data/sig/anthropic/models/messages/message_batch_individual_response.rbs +26 -0
- data/sig/anthropic/models/messages/message_batch_request_counts.rbs +38 -0
- data/sig/anthropic/models/messages/message_batch_result.rbs +19 -0
- data/sig/anthropic/models/messages/message_batch_succeeded_result.rbs +23 -0
- data/sig/anthropic/models/metadata.rbs +13 -0
- data/sig/anthropic/models/model.rbs +73 -0
- data/sig/anthropic/models/model_info.rbs +25 -0
- data/sig/anthropic/models/model_list_params.rbs +33 -0
- data/sig/anthropic/models/model_retrieve_params.rbs +15 -0
- data/sig/anthropic/models/not_found_error.rbs +15 -0
- data/sig/anthropic/models/overloaded_error.rbs +15 -0
- data/sig/anthropic/models/permission_error.rbs +15 -0
- data/sig/anthropic/models/plain_text_source.rbs +22 -0
- data/sig/anthropic/models/rate_limit_error.rbs +15 -0
- data/sig/anthropic/models/raw_content_block_delta.rbs +16 -0
- data/sig/anthropic/models/raw_content_block_delta_event.rbs +26 -0
- data/sig/anthropic/models/raw_content_block_start_event.rbs +38 -0
- data/sig/anthropic/models/raw_content_block_stop_event.rbs +16 -0
- data/sig/anthropic/models/raw_message_delta_event.rbs +42 -0
- data/sig/anthropic/models/raw_message_start_event.rbs +19 -0
- data/sig/anthropic/models/raw_message_stop_event.rbs +13 -0
- data/sig/anthropic/models/raw_message_stream_event.rbs +17 -0
- data/sig/anthropic/models/redacted_thinking_block.rbs +15 -0
- data/sig/anthropic/models/redacted_thinking_block_param.rbs +16 -0
- data/sig/anthropic/models/signature_delta.rbs +15 -0
- data/sig/anthropic/models/stop_reason.rbs +16 -0
- data/sig/anthropic/models/text_block.rbs +26 -0
- data/sig/anthropic/models/text_block_param.rbs +30 -0
- data/sig/anthropic/models/text_citation.rbs +14 -0
- data/sig/anthropic/models/text_citation_param.rbs +14 -0
- data/sig/anthropic/models/text_delta.rbs +15 -0
- data/sig/anthropic/models/thinking_block.rbs +22 -0
- data/sig/anthropic/models/thinking_block_param.rbs +22 -0
- data/sig/anthropic/models/thinking_config_disabled.rbs +13 -0
- data/sig/anthropic/models/thinking_config_enabled.rbs +15 -0
- data/sig/anthropic/models/thinking_config_param.rbs +13 -0
- data/sig/anthropic/models/thinking_delta.rbs +15 -0
- data/sig/anthropic/models/tool.rbs +44 -0
- data/sig/anthropic/models/tool_bash_20250124.rbs +26 -0
- data/sig/anthropic/models/tool_choice.rbs +15 -0
- data/sig/anthropic/models/tool_choice_any.rbs +17 -0
- data/sig/anthropic/models/tool_choice_auto.rbs +17 -0
- data/sig/anthropic/models/tool_choice_none.rbs +13 -0
- data/sig/anthropic/models/tool_choice_tool.rbs +24 -0
- data/sig/anthropic/models/tool_result_block_param.rbs +64 -0
- data/sig/anthropic/models/tool_text_editor_20250124.rbs +26 -0
- data/sig/anthropic/models/tool_union.rbs +14 -0
- data/sig/anthropic/models/tool_use_block.rbs +25 -0
- data/sig/anthropic/models/tool_use_block_param.rbs +34 -0
- data/sig/anthropic/models/url_image_source.rbs +15 -0
- data/sig/anthropic/models/url_pdf_source.rbs +15 -0
- data/sig/anthropic/models/usage.rbs +30 -0
- data/sig/anthropic/request_options.rbs +34 -0
- data/sig/anthropic/resources/beta/messages/batches.rbs +49 -0
- data/sig/anthropic/resources/beta/messages.rbs +56 -0
- data/sig/anthropic/resources/beta/models.rbs +21 -0
- data/sig/anthropic/resources/beta.rbs +11 -0
- data/sig/anthropic/resources/completions.rbs +31 -0
- data/sig/anthropic/resources/messages/batches.rbs +41 -0
- data/sig/anthropic/resources/messages.rbs +51 -0
- data/sig/anthropic/resources/models.rbs +19 -0
- data/sig/anthropic/version.rbs +3 -0
- data/sig/anthropic/vertex/client.rbs +34 -0
- metadata +746 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# @abstract
|
9
|
+
#
|
10
|
+
# @generic Elem
|
11
|
+
#
|
12
|
+
# Array of items of a given type.
|
13
|
+
class ArrayOf
|
14
|
+
include Anthropic::Internal::Type::Converter
|
15
|
+
|
16
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Anthropic::Internal::Type::Converter, Class]
|
17
|
+
#
|
18
|
+
# @param spec [Hash{Symbol=>Object}] .
|
19
|
+
#
|
20
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
21
|
+
#
|
22
|
+
# @option spec [Proc] :enum
|
23
|
+
#
|
24
|
+
# @option spec [Proc] :union
|
25
|
+
#
|
26
|
+
# @option spec [Boolean] :"nil?"
|
27
|
+
def self.[](type_info, spec = {}) = new(type_info, spec)
|
28
|
+
|
29
|
+
# @param other [Object]
|
30
|
+
#
|
31
|
+
# @return [Boolean]
|
32
|
+
def ===(other) = other.is_a?(Array) && other.all?(item_type)
|
33
|
+
|
34
|
+
# @param other [Object]
|
35
|
+
#
|
36
|
+
# @return [Boolean]
|
37
|
+
def ==(other)
|
38
|
+
# rubocop:disable Layout/LineLength
|
39
|
+
other.is_a?(Anthropic::Internal::Type::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type
|
40
|
+
# rubocop:enable Layout/LineLength
|
41
|
+
end
|
42
|
+
|
43
|
+
# @api private
|
44
|
+
#
|
45
|
+
# @param value [Array<Object>, Object]
|
46
|
+
#
|
47
|
+
# @param state [Hash{Symbol=>Object}] .
|
48
|
+
#
|
49
|
+
# @option state [Boolean, :strong] :strictness
|
50
|
+
#
|
51
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
52
|
+
#
|
53
|
+
# @option state [Integer] :branched
|
54
|
+
#
|
55
|
+
# @return [Array<Object>, Object]
|
56
|
+
def coerce(value, state:)
|
57
|
+
exactness = state.fetch(:exactness)
|
58
|
+
|
59
|
+
unless value.is_a?(Array)
|
60
|
+
exactness[:no] += 1
|
61
|
+
return value
|
62
|
+
end
|
63
|
+
|
64
|
+
target = item_type
|
65
|
+
exactness[:yes] += 1
|
66
|
+
value
|
67
|
+
.map do |item|
|
68
|
+
case [nilable?, item]
|
69
|
+
in [true, nil]
|
70
|
+
exactness[:yes] += 1
|
71
|
+
nil
|
72
|
+
else
|
73
|
+
Anthropic::Internal::Type::Converter.coerce(target, item, state: state)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# @api private
|
79
|
+
#
|
80
|
+
# @param value [Array<Object>, Object]
|
81
|
+
#
|
82
|
+
# @param state [Hash{Symbol=>Object}] .
|
83
|
+
#
|
84
|
+
# @option state [Boolean] :can_retry
|
85
|
+
#
|
86
|
+
# @return [Array<Object>, Object]
|
87
|
+
def dump(value, state:)
|
88
|
+
target = item_type
|
89
|
+
if value.is_a?(Array)
|
90
|
+
value.map do
|
91
|
+
Anthropic::Internal::Type::Converter.dump(target, _1, state: state)
|
92
|
+
end
|
93
|
+
else
|
94
|
+
super
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# @api private
|
99
|
+
#
|
100
|
+
# @return [generic<Elem>]
|
101
|
+
protected def item_type = @item_type_fn.call
|
102
|
+
|
103
|
+
# @api private
|
104
|
+
#
|
105
|
+
# @return [Boolean]
|
106
|
+
protected def nilable? = @nilable
|
107
|
+
|
108
|
+
# @api private
|
109
|
+
#
|
110
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Anthropic::Internal::Type::Converter, Class]
|
111
|
+
#
|
112
|
+
# @param spec [Hash{Symbol=>Object}] .
|
113
|
+
#
|
114
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
115
|
+
#
|
116
|
+
# @option spec [Proc] :enum
|
117
|
+
#
|
118
|
+
# @option spec [Proc] :union
|
119
|
+
#
|
120
|
+
# @option spec [Boolean] :"nil?"
|
121
|
+
def initialize(type_info, spec = {})
|
122
|
+
@item_type_fn = Anthropic::Internal::Type::Converter.type_info(type_info || spec)
|
123
|
+
@nilable = spec[:nil?]
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,380 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @abstract
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # `api_error_object` is a `Anthropic::Models::APIErrorObject`
|
10
|
+
# api_error_object => {
|
11
|
+
# message: message,
|
12
|
+
# type: type
|
13
|
+
# }
|
14
|
+
class BaseModel
|
15
|
+
extend Anthropic::Internal::Type::Converter
|
16
|
+
|
17
|
+
class << self
|
18
|
+
# @api private
|
19
|
+
#
|
20
|
+
# Assumes superclass fields are totally defined before fields are accessed /
|
21
|
+
# defined on subclasses.
|
22
|
+
#
|
23
|
+
# @return [Hash{Symbol=>Hash{Symbol=>Object}}]
|
24
|
+
def known_fields
|
25
|
+
@known_fields ||= (self < Anthropic::Internal::Type::BaseModel ? superclass.known_fields.dup : {})
|
26
|
+
end
|
27
|
+
|
28
|
+
# @api private
|
29
|
+
#
|
30
|
+
# @return [Hash{Symbol=>Hash{Symbol=>Object}}]
|
31
|
+
def fields
|
32
|
+
known_fields.transform_values do |field|
|
33
|
+
{**field.except(:type_fn), type: field.fetch(:type_fn).call}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @api private
|
38
|
+
#
|
39
|
+
# @param name_sym [Symbol]
|
40
|
+
#
|
41
|
+
# @param required [Boolean]
|
42
|
+
#
|
43
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Anthropic::Internal::Type::Converter, Class]
|
44
|
+
#
|
45
|
+
# @param spec [Hash{Symbol=>Object}] .
|
46
|
+
#
|
47
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
48
|
+
#
|
49
|
+
# @option spec [Proc] :enum
|
50
|
+
#
|
51
|
+
# @option spec [Proc] :union
|
52
|
+
#
|
53
|
+
# @option spec [Boolean] :"nil?"
|
54
|
+
private def add_field(name_sym, required:, type_info:, spec:)
|
55
|
+
type_fn, info =
|
56
|
+
case type_info
|
57
|
+
in Proc | Anthropic::Internal::Type::Converter | Class
|
58
|
+
[Anthropic::Internal::Type::Converter.type_info({**spec, union: type_info}), spec]
|
59
|
+
in Hash
|
60
|
+
[Anthropic::Internal::Type::Converter.type_info(type_info), type_info]
|
61
|
+
end
|
62
|
+
|
63
|
+
setter = "#{name_sym}="
|
64
|
+
api_name = info.fetch(:api_name, name_sym)
|
65
|
+
nilable = info[:nil?]
|
66
|
+
const = if required && !nilable
|
67
|
+
info.fetch(
|
68
|
+
:const,
|
69
|
+
Anthropic::Internal::OMIT
|
70
|
+
)
|
71
|
+
else
|
72
|
+
Anthropic::Internal::OMIT
|
73
|
+
end
|
74
|
+
|
75
|
+
[name_sym, setter].each { undef_method(_1) } if known_fields.key?(name_sym)
|
76
|
+
|
77
|
+
known_fields[name_sym] =
|
78
|
+
{
|
79
|
+
mode: @mode,
|
80
|
+
api_name: api_name,
|
81
|
+
required: required,
|
82
|
+
nilable: nilable,
|
83
|
+
const: const,
|
84
|
+
type_fn: type_fn
|
85
|
+
}
|
86
|
+
|
87
|
+
define_method(setter) { @data.store(name_sym, _1) }
|
88
|
+
|
89
|
+
define_method(name_sym) do
|
90
|
+
target = type_fn.call
|
91
|
+
value = @data.fetch(name_sym) { const == Anthropic::Internal::OMIT ? nil : const }
|
92
|
+
state = {strictness: :strong, exactness: {yes: 0, no: 0, maybe: 0}, branched: 0}
|
93
|
+
if (nilable || !required) && value.nil?
|
94
|
+
nil
|
95
|
+
else
|
96
|
+
Anthropic::Internal::Type::Converter.coerce(
|
97
|
+
target, value, state: state
|
98
|
+
)
|
99
|
+
end
|
100
|
+
rescue StandardError
|
101
|
+
cls = self.class.name.split("::").last
|
102
|
+
# rubocop:disable Layout/LineLength
|
103
|
+
message = "Failed to parse #{cls}.#{__method__} from #{value.class} to #{target.inspect}. To get the unparsed API response, use #{cls}[:#{__method__}]."
|
104
|
+
# rubocop:enable Layout/LineLength
|
105
|
+
raise Anthropic::Errors::ConversionError.new(message)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# @api private
|
110
|
+
#
|
111
|
+
# @param name_sym [Symbol]
|
112
|
+
#
|
113
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Anthropic::Internal::Type::Converter, Class]
|
114
|
+
#
|
115
|
+
# @param spec [Hash{Symbol=>Object}] .
|
116
|
+
#
|
117
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
118
|
+
#
|
119
|
+
# @option spec [Proc] :enum
|
120
|
+
#
|
121
|
+
# @option spec [Proc] :union
|
122
|
+
#
|
123
|
+
# @option spec [Boolean] :"nil?"
|
124
|
+
def required(name_sym, type_info, spec = {})
|
125
|
+
add_field(name_sym, required: true, type_info: type_info, spec: spec)
|
126
|
+
end
|
127
|
+
|
128
|
+
# @api private
|
129
|
+
#
|
130
|
+
# @param name_sym [Symbol]
|
131
|
+
#
|
132
|
+
# @param type_info [Hash{Symbol=>Object}, Proc, Anthropic::Internal::Type::Converter, Class]
|
133
|
+
#
|
134
|
+
# @param spec [Hash{Symbol=>Object}] .
|
135
|
+
#
|
136
|
+
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
137
|
+
#
|
138
|
+
# @option spec [Proc] :enum
|
139
|
+
#
|
140
|
+
# @option spec [Proc] :union
|
141
|
+
#
|
142
|
+
# @option spec [Boolean] :"nil?"
|
143
|
+
def optional(name_sym, type_info, spec = {})
|
144
|
+
add_field(name_sym, required: false, type_info: type_info, spec: spec)
|
145
|
+
end
|
146
|
+
|
147
|
+
# @api private
|
148
|
+
#
|
149
|
+
# `request_only` attributes not excluded from `.#coerce` when receiving responses
|
150
|
+
# even if well behaved servers should not send them
|
151
|
+
#
|
152
|
+
# @param blk [Proc]
|
153
|
+
private def request_only(&blk)
|
154
|
+
@mode = :dump
|
155
|
+
blk.call
|
156
|
+
ensure
|
157
|
+
@mode = nil
|
158
|
+
end
|
159
|
+
|
160
|
+
# @api private
|
161
|
+
#
|
162
|
+
# `response_only` attributes are omitted from `.#dump` when making requests
|
163
|
+
#
|
164
|
+
# @param blk [Proc]
|
165
|
+
private def response_only(&blk)
|
166
|
+
@mode = :coerce
|
167
|
+
blk.call
|
168
|
+
ensure
|
169
|
+
@mode = nil
|
170
|
+
end
|
171
|
+
|
172
|
+
# @param other [Object]
|
173
|
+
#
|
174
|
+
# @return [Boolean]
|
175
|
+
def ==(other)
|
176
|
+
other.is_a?(Class) && other <= Anthropic::Internal::Type::BaseModel && other.fields == fields
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
# @param other [Object]
|
181
|
+
#
|
182
|
+
# @return [Boolean]
|
183
|
+
def ==(other) = self.class == other.class && @data == other.to_h
|
184
|
+
|
185
|
+
class << self
|
186
|
+
# @api private
|
187
|
+
#
|
188
|
+
# @param value [Anthropic::Internal::Type::BaseModel, Hash{Object=>Object}, Object]
|
189
|
+
#
|
190
|
+
# @param state [Hash{Symbol=>Object}] .
|
191
|
+
#
|
192
|
+
# @option state [Boolean, :strong] :strictness
|
193
|
+
#
|
194
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
195
|
+
#
|
196
|
+
# @option state [Integer] :branched
|
197
|
+
#
|
198
|
+
# @return [Anthropic::Internal::Type::BaseModel, Object]
|
199
|
+
def coerce(value, state:)
|
200
|
+
exactness = state.fetch(:exactness)
|
201
|
+
|
202
|
+
if value.is_a?(self.class)
|
203
|
+
exactness[:yes] += 1
|
204
|
+
return value
|
205
|
+
end
|
206
|
+
|
207
|
+
unless (val = Anthropic::Internal::Util.coerce_hash(value)).is_a?(Hash)
|
208
|
+
exactness[:no] += 1
|
209
|
+
return value
|
210
|
+
end
|
211
|
+
exactness[:yes] += 1
|
212
|
+
|
213
|
+
keys = val.keys.to_set
|
214
|
+
instance = new
|
215
|
+
data = instance.to_h
|
216
|
+
|
217
|
+
# rubocop:disable Metrics/BlockLength
|
218
|
+
fields.each do |name, field|
|
219
|
+
mode, required, target = field.fetch_values(:mode, :required, :type)
|
220
|
+
api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const)
|
221
|
+
|
222
|
+
unless val.key?(api_name)
|
223
|
+
if required && mode != :dump && const == Anthropic::Internal::OMIT
|
224
|
+
exactness[nilable ? :maybe : :no] += 1
|
225
|
+
else
|
226
|
+
exactness[:yes] += 1
|
227
|
+
end
|
228
|
+
next
|
229
|
+
end
|
230
|
+
|
231
|
+
item = val.fetch(api_name)
|
232
|
+
keys.delete(api_name)
|
233
|
+
|
234
|
+
converted =
|
235
|
+
if item.nil? && (nilable || !required)
|
236
|
+
exactness[nilable ? :yes : :maybe] += 1
|
237
|
+
nil
|
238
|
+
else
|
239
|
+
coerced = Anthropic::Internal::Type::Converter.coerce(target, item, state: state)
|
240
|
+
case target
|
241
|
+
in Anthropic::Internal::Type::Converter | Symbol
|
242
|
+
coerced
|
243
|
+
else
|
244
|
+
item
|
245
|
+
end
|
246
|
+
end
|
247
|
+
data.store(name, converted)
|
248
|
+
end
|
249
|
+
# rubocop:enable Metrics/BlockLength
|
250
|
+
|
251
|
+
keys.each { data.store(_1, val.fetch(_1)) }
|
252
|
+
instance
|
253
|
+
end
|
254
|
+
|
255
|
+
# @api private
|
256
|
+
#
|
257
|
+
# @param value [Anthropic::Internal::Type::BaseModel, Object]
|
258
|
+
#
|
259
|
+
# @param state [Hash{Symbol=>Object}] .
|
260
|
+
#
|
261
|
+
# @option state [Boolean] :can_retry
|
262
|
+
#
|
263
|
+
# @return [Hash{Object=>Object}, Object]
|
264
|
+
def dump(value, state:)
|
265
|
+
unless (coerced = Anthropic::Internal::Util.coerce_hash(value)).is_a?(Hash)
|
266
|
+
return super
|
267
|
+
end
|
268
|
+
|
269
|
+
acc = {}
|
270
|
+
|
271
|
+
coerced.each do |key, val|
|
272
|
+
name = key.is_a?(String) ? key.to_sym : key
|
273
|
+
case (field = known_fields[name])
|
274
|
+
in nil
|
275
|
+
acc.store(name, super(val, state: state))
|
276
|
+
else
|
277
|
+
api_name, mode, type_fn = field.fetch_values(:api_name, :mode, :type_fn)
|
278
|
+
case mode
|
279
|
+
in :coerce
|
280
|
+
next
|
281
|
+
else
|
282
|
+
target = type_fn.call
|
283
|
+
acc.store(api_name, Anthropic::Internal::Type::Converter.dump(target, val, state: state))
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
known_fields.each_value do |field|
|
289
|
+
api_name, mode, const = field.fetch_values(:api_name, :mode, :const)
|
290
|
+
next if mode == :coerce || acc.key?(api_name) || const == Anthropic::Internal::OMIT
|
291
|
+
acc.store(api_name, const)
|
292
|
+
end
|
293
|
+
|
294
|
+
acc
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
# Returns the raw value associated with the given key, if found. Otherwise, nil is
|
299
|
+
# returned.
|
300
|
+
#
|
301
|
+
# It is valid to lookup keys that are not in the API spec, for example to access
|
302
|
+
# undocumented features. This method does not parse response data into
|
303
|
+
# higher-level types. Lookup by anything other than a Symbol is an ArgumentError.
|
304
|
+
#
|
305
|
+
# @param key [Symbol]
|
306
|
+
#
|
307
|
+
# @return [Object, nil]
|
308
|
+
def [](key)
|
309
|
+
unless key.instance_of?(Symbol)
|
310
|
+
raise ArgumentError.new("Expected symbol key for lookup, got #{key.inspect}")
|
311
|
+
end
|
312
|
+
|
313
|
+
@data[key]
|
314
|
+
end
|
315
|
+
|
316
|
+
# Returns a Hash of the data underlying this object. O(1)
|
317
|
+
#
|
318
|
+
# Keys are Symbols and values are the raw values from the response. The return
|
319
|
+
# value indicates which values were ever set on the object. i.e. there will be a
|
320
|
+
# key in this hash if they ever were, even if the set value was nil.
|
321
|
+
#
|
322
|
+
# This method is not recursive. The returned value is shared by the object, so it
|
323
|
+
# should not be mutated.
|
324
|
+
#
|
325
|
+
# @return [Hash{Symbol=>Object}]
|
326
|
+
def to_h = @data
|
327
|
+
|
328
|
+
alias_method :to_hash, :to_h
|
329
|
+
|
330
|
+
# @param keys [Array<Symbol>, nil]
|
331
|
+
#
|
332
|
+
# @return [Hash{Symbol=>Object}]
|
333
|
+
def deconstruct_keys(keys)
|
334
|
+
(keys || self.class.known_fields.keys)
|
335
|
+
.filter_map do |k|
|
336
|
+
unless self.class.known_fields.key?(k)
|
337
|
+
next
|
338
|
+
end
|
339
|
+
|
340
|
+
[k, public_send(k)]
|
341
|
+
end
|
342
|
+
.to_h
|
343
|
+
end
|
344
|
+
|
345
|
+
# @param a [Object]
|
346
|
+
#
|
347
|
+
# @return [String]
|
348
|
+
def to_json(*a) = Anthropic::Internal::Type::Converter.dump(self.class, self).to_json(*a)
|
349
|
+
|
350
|
+
# @param a [Object]
|
351
|
+
#
|
352
|
+
# @return [String]
|
353
|
+
def to_yaml(*a) = Anthropic::Internal::Type::Converter.dump(self.class, self).to_yaml(*a)
|
354
|
+
|
355
|
+
# Create a new instance of a model.
|
356
|
+
#
|
357
|
+
# @param data [Hash{Symbol=>Object}, Anthropic::Internal::Type::BaseModel]
|
358
|
+
def initialize(data = {})
|
359
|
+
case Anthropic::Internal::Util.coerce_hash(data)
|
360
|
+
in Hash => coerced
|
361
|
+
@data = coerced
|
362
|
+
else
|
363
|
+
message = "Expected a #{Hash} or #{Anthropic::Internal::Type::BaseModel}, got #{data.inspect}"
|
364
|
+
raise ArgumentError.new(message)
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
# @return [String]
|
369
|
+
def inspect
|
370
|
+
rows = self.class.known_fields.keys.map do
|
371
|
+
"#{_1}=#{@data.key?(_1) ? public_send(_1) : ''}"
|
372
|
+
rescue Anthropic::Errors::ConversionError
|
373
|
+
"#{_1}=#{@data.fetch(_1)}"
|
374
|
+
end
|
375
|
+
"#<#{self.class.name}:0x#{object_id.to_s(16)} #{rows.join(' ')}>"
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @generic Elem
|
7
|
+
#
|
8
|
+
# This module provides a base implementation for paginated responses in the SDK.
|
9
|
+
module BasePage
|
10
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
11
|
+
|
12
|
+
# @return [Boolean]
|
13
|
+
def next_page? = (raise NotImplementedError)
|
14
|
+
|
15
|
+
# @raise [Anthropic::Errors::APIError]
|
16
|
+
# @return [Anthropic::Internal::Type::BasePage]
|
17
|
+
def next_page = (raise NotImplementedError)
|
18
|
+
|
19
|
+
# @param blk [Proc]
|
20
|
+
#
|
21
|
+
# @yieldparam [generic<Elem>]
|
22
|
+
# @return [void]
|
23
|
+
def auto_paging_each(&blk) = (raise NotImplementedError)
|
24
|
+
|
25
|
+
# @return [Enumerable<generic<Elem>>]
|
26
|
+
def to_enum = super(:auto_paging_each)
|
27
|
+
|
28
|
+
alias_method :enum_for, :to_enum
|
29
|
+
|
30
|
+
# @api private
|
31
|
+
#
|
32
|
+
# @param client [Anthropic::Internal::Transport::BaseClient]
|
33
|
+
# @param req [Hash{Symbol=>Object}]
|
34
|
+
# @param headers [Hash{String=>String}, Net::HTTPHeader]
|
35
|
+
# @param page_data [Object]
|
36
|
+
def initialize(client:, req:, headers:, page_data:)
|
37
|
+
@client = client
|
38
|
+
@req = req
|
39
|
+
super()
|
40
|
+
end
|
41
|
+
|
42
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @generic Elem
|
7
|
+
#
|
8
|
+
# This module provides a base implementation for streaming responses in the SDK.
|
9
|
+
#
|
10
|
+
# @see https://rubyapi.org/3.1/o/enumerable
|
11
|
+
module BaseStream
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# Attempt to close the underlying transport when the stream itself is garbage
|
16
|
+
# collected.
|
17
|
+
#
|
18
|
+
# This should not be relied upon for resource clean up, as the garbage collector
|
19
|
+
# is not guaranteed to run.
|
20
|
+
#
|
21
|
+
# @param stream [Enumerable<Object>]
|
22
|
+
#
|
23
|
+
# @return [Proc]
|
24
|
+
#
|
25
|
+
# @see https://rubyapi.org/3.1/o/objectspace#method-c-define_finalizer
|
26
|
+
def defer_closing(stream) = ->(_id) { Anthropic::Internal::Util.close_fused!(stream) }
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [void]
|
30
|
+
def close = Anthropic::Internal::Util.close_fused!(@iterator)
|
31
|
+
|
32
|
+
# @api private
|
33
|
+
#
|
34
|
+
# @return [Enumerable<generic<Elem>>]
|
35
|
+
private def iterator = (raise NotImplementedError)
|
36
|
+
|
37
|
+
# @param blk [Proc]
|
38
|
+
#
|
39
|
+
# @yieldparam [generic<Elem>]
|
40
|
+
# @return [void]
|
41
|
+
def each(&blk)
|
42
|
+
unless block_given?
|
43
|
+
raise ArgumentError.new("A block must be given to ##{__method__}")
|
44
|
+
end
|
45
|
+
@iterator.each(&blk)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [Enumerator<generic<Elem>>]
|
49
|
+
def to_enum = @iterator
|
50
|
+
|
51
|
+
alias_method :enum_for, :to_enum
|
52
|
+
|
53
|
+
# @api private
|
54
|
+
#
|
55
|
+
# @param model [Class, Anthropic::Internal::Type::Converter]
|
56
|
+
# @param url [URI::Generic]
|
57
|
+
# @param status [Integer]
|
58
|
+
# @param response [Net::HTTPResponse]
|
59
|
+
# @param stream [Enumerable<Object>]
|
60
|
+
def initialize(model:, url:, status:, response:, stream:)
|
61
|
+
@model = model
|
62
|
+
@url = url
|
63
|
+
@status = status
|
64
|
+
@response = response
|
65
|
+
@stream = stream
|
66
|
+
@iterator = iterator
|
67
|
+
|
68
|
+
ObjectSpace.define_finalizer(self, Anthropic::Internal::Type::BaseStream.defer_closing(@stream))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Anthropic
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# @abstract
|
9
|
+
#
|
10
|
+
# Ruby has no Boolean class; this is something for models to refer to.
|
11
|
+
class Boolean
|
12
|
+
extend Anthropic::Internal::Type::Converter
|
13
|
+
|
14
|
+
# @param other [Object]
|
15
|
+
#
|
16
|
+
# @return [Boolean]
|
17
|
+
def self.===(other) = other == true || other == false
|
18
|
+
|
19
|
+
# @param other [Object]
|
20
|
+
#
|
21
|
+
# @return [Boolean]
|
22
|
+
def self.==(other) = other.is_a?(Class) && other <= Anthropic::Internal::Type::Boolean
|
23
|
+
|
24
|
+
class << self
|
25
|
+
# @api private
|
26
|
+
#
|
27
|
+
# @param value [Boolean, Object]
|
28
|
+
#
|
29
|
+
# @param state [Hash{Symbol=>Object}] .
|
30
|
+
#
|
31
|
+
# @option state [Boolean, :strong] :strictness
|
32
|
+
#
|
33
|
+
# @option state [Hash{Symbol=>Object}] :exactness
|
34
|
+
#
|
35
|
+
# @option state [Integer] :branched
|
36
|
+
#
|
37
|
+
# @return [Boolean, Object]
|
38
|
+
def coerce(value, state:)
|
39
|
+
state.fetch(:exactness)[value == true || value == false ? :yes : :no] += 1
|
40
|
+
value
|
41
|
+
end
|
42
|
+
|
43
|
+
# @!parse
|
44
|
+
# # @api private
|
45
|
+
# #
|
46
|
+
# # @param value [Boolean, Object]
|
47
|
+
# #
|
48
|
+
# # @param state [Hash{Symbol=>Object}] .
|
49
|
+
# #
|
50
|
+
# # @option state [Boolean] :can_retry
|
51
|
+
# #
|
52
|
+
# # @return [Boolean, Object]
|
53
|
+
# def dump(value, state:) = super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|