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
@@ -43,6 +43,8 @@ module Anthropic
|
|
43
43
|
Anthropic::Tool::OrHash,
|
44
44
|
Anthropic::ToolBash20250124::OrHash,
|
45
45
|
Anthropic::ToolTextEditor20250124::OrHash,
|
46
|
+
Anthropic::ToolTextEditor20250429::OrHash,
|
47
|
+
Anthropic::ToolTextEditor20250728::OrHash,
|
46
48
|
Anthropic::WebSearchTool20250305::OrHash
|
47
49
|
)
|
48
50
|
],
|
@@ -53,6 +55,298 @@ module Anthropic
|
|
53
55
|
).returns(Anthropic::Message)
|
54
56
|
end
|
55
57
|
def create(
|
58
|
+
# The maximum number of tokens to generate before stopping.
|
59
|
+
#
|
60
|
+
# Note that our models may stop _before_ reaching this maximum. This parameter
|
61
|
+
# only specifies the absolute maximum number of tokens to generate.
|
62
|
+
#
|
63
|
+
# Different models have different maximum values for this parameter. See
|
64
|
+
# [models](https://docs.anthropic.com/en/docs/models-overview) for details.
|
65
|
+
max_tokens:,
|
66
|
+
# Input messages.
|
67
|
+
#
|
68
|
+
# Our models are trained to operate on alternating `user` and `assistant`
|
69
|
+
# conversational turns. When creating a new `Message`, you specify the prior
|
70
|
+
# conversational turns with the `messages` parameter, and the model then generates
|
71
|
+
# the next `Message` in the conversation. Consecutive `user` or `assistant` turns
|
72
|
+
# in your request will be combined into a single turn.
|
73
|
+
#
|
74
|
+
# Each input message must be an object with a `role` and `content`. You can
|
75
|
+
# specify a single `user`-role message, or you can include multiple `user` and
|
76
|
+
# `assistant` messages.
|
77
|
+
#
|
78
|
+
# If the final message uses the `assistant` role, the response content will
|
79
|
+
# continue immediately from the content in that message. This can be used to
|
80
|
+
# constrain part of the model's response.
|
81
|
+
#
|
82
|
+
# Example with a single `user` message:
|
83
|
+
#
|
84
|
+
# ```json
|
85
|
+
# [{ "role": "user", "content": "Hello, Claude" }]
|
86
|
+
# ```
|
87
|
+
#
|
88
|
+
# Example with multiple conversational turns:
|
89
|
+
#
|
90
|
+
# ```json
|
91
|
+
# [
|
92
|
+
# { "role": "user", "content": "Hello there." },
|
93
|
+
# { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
|
94
|
+
# { "role": "user", "content": "Can you explain LLMs in plain English?" }
|
95
|
+
# ]
|
96
|
+
# ```
|
97
|
+
#
|
98
|
+
# Example with a partially-filled response from Claude:
|
99
|
+
#
|
100
|
+
# ```json
|
101
|
+
# [
|
102
|
+
# {
|
103
|
+
# "role": "user",
|
104
|
+
# "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
|
105
|
+
# },
|
106
|
+
# { "role": "assistant", "content": "The best answer is (" }
|
107
|
+
# ]
|
108
|
+
# ```
|
109
|
+
#
|
110
|
+
# Each input message `content` may be either a single `string` or an array of
|
111
|
+
# content blocks, where each block has a specific `type`. Using a `string` for
|
112
|
+
# `content` is shorthand for an array of one content block of type `"text"`. The
|
113
|
+
# following input messages are equivalent:
|
114
|
+
#
|
115
|
+
# ```json
|
116
|
+
# { "role": "user", "content": "Hello, Claude" }
|
117
|
+
# ```
|
118
|
+
#
|
119
|
+
# ```json
|
120
|
+
# { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
121
|
+
# ```
|
122
|
+
#
|
123
|
+
# See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
124
|
+
#
|
125
|
+
# Note that if you want to include a
|
126
|
+
# [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
127
|
+
# the top-level `system` parameter — there is no `"system"` role for input
|
128
|
+
# messages in the Messages API.
|
129
|
+
#
|
130
|
+
# There is a limit of 100,000 messages in a single request.
|
131
|
+
messages:,
|
132
|
+
# The model that will complete your prompt.\n\nSee
|
133
|
+
# [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
134
|
+
# details and options.
|
135
|
+
model:,
|
136
|
+
# An object describing metadata about the request.
|
137
|
+
metadata: nil,
|
138
|
+
# Determines whether to use priority capacity (if available) or standard capacity
|
139
|
+
# for this request.
|
140
|
+
#
|
141
|
+
# Anthropic offers different levels of service for your API requests. See
|
142
|
+
# [service-tiers](https://docs.anthropic.com/en/api/service-tiers) for details.
|
143
|
+
service_tier: nil,
|
144
|
+
# Custom text sequences that will cause the model to stop generating.
|
145
|
+
#
|
146
|
+
# Our models will normally stop when they have naturally completed their turn,
|
147
|
+
# which will result in a response `stop_reason` of `"end_turn"`.
|
148
|
+
#
|
149
|
+
# If you want the model to stop generating when it encounters custom strings of
|
150
|
+
# text, you can use the `stop_sequences` parameter. If the model encounters one of
|
151
|
+
# the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
|
152
|
+
# and the response `stop_sequence` value will contain the matched stop sequence.
|
153
|
+
stop_sequences: nil,
|
154
|
+
# System prompt.
|
155
|
+
#
|
156
|
+
# A system prompt is a way of providing context and instructions to Claude, such
|
157
|
+
# as specifying a particular goal or role. See our
|
158
|
+
# [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
|
159
|
+
system_: nil,
|
160
|
+
# Amount of randomness injected into the response.
|
161
|
+
#
|
162
|
+
# Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
|
163
|
+
# for analytical / multiple choice, and closer to `1.0` for creative and
|
164
|
+
# generative tasks.
|
165
|
+
#
|
166
|
+
# Note that even with `temperature` of `0.0`, the results will not be fully
|
167
|
+
# deterministic.
|
168
|
+
temperature: nil,
|
169
|
+
# Configuration for enabling Claude's extended thinking.
|
170
|
+
#
|
171
|
+
# When enabled, responses include `thinking` content blocks showing Claude's
|
172
|
+
# thinking process before the final answer. Requires a minimum budget of 1,024
|
173
|
+
# tokens and counts towards your `max_tokens` limit.
|
174
|
+
#
|
175
|
+
# See
|
176
|
+
# [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
|
177
|
+
# for details.
|
178
|
+
thinking: nil,
|
179
|
+
# How the model should use the provided tools. The model can use a specific tool,
|
180
|
+
# any available tool, decide by itself, or not use tools at all.
|
181
|
+
tool_choice: nil,
|
182
|
+
# Definitions of tools that the model may use.
|
183
|
+
#
|
184
|
+
# If you include `tools` in your API request, the model may return `tool_use`
|
185
|
+
# content blocks that represent the model's use of those tools. You can then run
|
186
|
+
# those tools using the tool input generated by the model and then optionally
|
187
|
+
# return results back to the model using `tool_result` content blocks.
|
188
|
+
#
|
189
|
+
# There are two types of tools: **client tools** and **server tools**. The
|
190
|
+
# behavior described below applies to client tools. For
|
191
|
+
# [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
|
192
|
+
# see their individual documentation as each has its own behavior (e.g., the
|
193
|
+
# [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
|
194
|
+
#
|
195
|
+
# Each tool definition includes:
|
196
|
+
#
|
197
|
+
# - `name`: Name of the tool.
|
198
|
+
# - `description`: Optional, but strongly-recommended description of the tool.
|
199
|
+
# - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
|
200
|
+
# tool `input` shape that the model will produce in `tool_use` output content
|
201
|
+
# blocks.
|
202
|
+
#
|
203
|
+
# For example, if you defined `tools` as:
|
204
|
+
#
|
205
|
+
# ```json
|
206
|
+
# [
|
207
|
+
# {
|
208
|
+
# "name": "get_stock_price",
|
209
|
+
# "description": "Get the current stock price for a given ticker symbol.",
|
210
|
+
# "input_schema": {
|
211
|
+
# "type": "object",
|
212
|
+
# "properties": {
|
213
|
+
# "ticker": {
|
214
|
+
# "type": "string",
|
215
|
+
# "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
|
216
|
+
# }
|
217
|
+
# },
|
218
|
+
# "required": ["ticker"]
|
219
|
+
# }
|
220
|
+
# }
|
221
|
+
# ]
|
222
|
+
# ```
|
223
|
+
#
|
224
|
+
# And then asked the model "What's the S&P 500 at today?", the model might produce
|
225
|
+
# `tool_use` content blocks in the response like this:
|
226
|
+
#
|
227
|
+
# ```json
|
228
|
+
# [
|
229
|
+
# {
|
230
|
+
# "type": "tool_use",
|
231
|
+
# "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
|
232
|
+
# "name": "get_stock_price",
|
233
|
+
# "input": { "ticker": "^GSPC" }
|
234
|
+
# }
|
235
|
+
# ]
|
236
|
+
# ```
|
237
|
+
#
|
238
|
+
# You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
|
239
|
+
# input, and return the following back to the model in a subsequent `user`
|
240
|
+
# message:
|
241
|
+
#
|
242
|
+
# ```json
|
243
|
+
# [
|
244
|
+
# {
|
245
|
+
# "type": "tool_result",
|
246
|
+
# "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
|
247
|
+
# "content": "259.75 USD"
|
248
|
+
# }
|
249
|
+
# ]
|
250
|
+
# ```
|
251
|
+
#
|
252
|
+
# Tools can be used for workflows that include running client-side tools and
|
253
|
+
# functions, or more generally whenever you want the model to produce a particular
|
254
|
+
# JSON structure of output.
|
255
|
+
#
|
256
|
+
# See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
|
257
|
+
tools: nil,
|
258
|
+
# Only sample from the top K options for each subsequent token.
|
259
|
+
#
|
260
|
+
# Used to remove "long tail" low probability responses.
|
261
|
+
# [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
|
262
|
+
#
|
263
|
+
# Recommended for advanced use cases only. You usually only need to use
|
264
|
+
# `temperature`.
|
265
|
+
top_k: nil,
|
266
|
+
# Use nucleus sampling.
|
267
|
+
#
|
268
|
+
# In nucleus sampling, we compute the cumulative distribution over all the options
|
269
|
+
# for each subsequent token in decreasing probability order and cut it off once it
|
270
|
+
# reaches a particular probability specified by `top_p`. You should either alter
|
271
|
+
# `temperature` or `top_p`, but not both.
|
272
|
+
#
|
273
|
+
# Recommended for advanced use cases only. You usually only need to use
|
274
|
+
# `temperature`.
|
275
|
+
top_p: nil,
|
276
|
+
# There is no need to provide `stream:`. Instead, use `#stream_raw` or `#create`
|
277
|
+
# for streaming and non-streaming use cases, respectively.
|
278
|
+
stream: false,
|
279
|
+
request_options: {}
|
280
|
+
)
|
281
|
+
end
|
282
|
+
|
283
|
+
# See {Anthropic::Resources::Messages#create} for non-streaming counterpart.
|
284
|
+
#
|
285
|
+
# Send a structured list of input messages with text and/or image content, and the
|
286
|
+
# model will generate the next message in the conversation.
|
287
|
+
#
|
288
|
+
# The Messages API can be used for either single queries or stateless multi-turn
|
289
|
+
# conversations.
|
290
|
+
#
|
291
|
+
# Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
|
292
|
+
sig do
|
293
|
+
params(
|
294
|
+
max_tokens: Integer,
|
295
|
+
messages:
|
296
|
+
T::Array[
|
297
|
+
T.any(
|
298
|
+
Anthropic::Models::MessageParam,
|
299
|
+
Anthropic::Internal::AnyHash
|
300
|
+
)
|
301
|
+
],
|
302
|
+
model: T.any(Anthropic::Models::Model::OrSymbol, String),
|
303
|
+
metadata:
|
304
|
+
T.any(Anthropic::Models::Metadata, Anthropic::Internal::AnyHash),
|
305
|
+
stop_sequences: T::Array[String],
|
306
|
+
system_:
|
307
|
+
T.any(
|
308
|
+
String,
|
309
|
+
T::Array[
|
310
|
+
T.any(
|
311
|
+
Anthropic::Models::TextBlockParam,
|
312
|
+
Anthropic::Internal::AnyHash
|
313
|
+
)
|
314
|
+
]
|
315
|
+
),
|
316
|
+
temperature: Float,
|
317
|
+
thinking:
|
318
|
+
T.any(
|
319
|
+
Anthropic::Models::ThinkingConfigEnabled,
|
320
|
+
Anthropic::Internal::AnyHash,
|
321
|
+
Anthropic::Models::ThinkingConfigDisabled
|
322
|
+
),
|
323
|
+
tool_choice:
|
324
|
+
T.any(
|
325
|
+
Anthropic::Models::ToolChoiceAuto,
|
326
|
+
Anthropic::Internal::AnyHash,
|
327
|
+
Anthropic::Models::ToolChoiceAny,
|
328
|
+
Anthropic::Models::ToolChoiceTool,
|
329
|
+
Anthropic::Models::ToolChoiceNone
|
330
|
+
),
|
331
|
+
tools:
|
332
|
+
T::Array[
|
333
|
+
T.any(
|
334
|
+
Anthropic::Models::Tool,
|
335
|
+
Anthropic::Internal::AnyHash,
|
336
|
+
Anthropic::Models::ToolBash20250124,
|
337
|
+
Anthropic::Models::ToolTextEditor20250124
|
338
|
+
)
|
339
|
+
],
|
340
|
+
top_k: Integer,
|
341
|
+
top_p: Float,
|
342
|
+
stream: T.noreturn,
|
343
|
+
request_options:
|
344
|
+
T.nilable(
|
345
|
+
T.any(Anthropic::RequestOptions, Anthropic::Internal::AnyHash)
|
346
|
+
)
|
347
|
+
).returns(Anthropic::Helpers::Streaming::MessageStream)
|
348
|
+
end
|
349
|
+
def stream(
|
56
350
|
# The maximum number of tokens to generate before stopping.
|
57
351
|
#
|
58
352
|
# Note that our models may stop _before_ reaching this maximum. This parameter
|
@@ -147,8 +441,6 @@ module Anthropic
|
|
147
441
|
# [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
148
442
|
# the top-level `system` parameter — there is no `"system"` role for input
|
149
443
|
# messages in the Messages API.
|
150
|
-
#
|
151
|
-
# There is a limit of 100000 messages in a single request.
|
152
444
|
messages:,
|
153
445
|
# The model that will complete your prompt.\n\nSee
|
154
446
|
# [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
@@ -156,12 +448,6 @@ module Anthropic
|
|
156
448
|
model:,
|
157
449
|
# An object describing metadata about the request.
|
158
450
|
metadata: nil,
|
159
|
-
# Determines whether to use priority capacity (if available) or standard capacity
|
160
|
-
# for this request.
|
161
|
-
#
|
162
|
-
# Anthropic offers different levels of service for your API requests. See
|
163
|
-
# [service-tiers](https://docs.anthropic.com/en/api/service-tiers) for details.
|
164
|
-
service_tier: nil,
|
165
451
|
# Custom text sequences that will cause the model to stop generating.
|
166
452
|
#
|
167
453
|
# Our models will normally stop when they have naturally completed their turn,
|
@@ -290,20 +576,10 @@ module Anthropic
|
|
290
576
|
top_p: nil,
|
291
577
|
# There is no need to provide `stream:`. Instead, use `#stream_raw` or `#create`
|
292
578
|
# for streaming and non-streaming use cases, respectively.
|
293
|
-
stream:
|
579
|
+
stream: true,
|
294
580
|
request_options: {}
|
295
581
|
)
|
296
582
|
end
|
297
|
-
|
298
|
-
# See {Anthropic::Resources::Messages#create} for non-streaming counterpart.
|
299
|
-
#
|
300
|
-
# Send a structured list of input messages with text and/or image content, and the
|
301
|
-
# model will generate the next message in the conversation.
|
302
|
-
#
|
303
|
-
# The Messages API can be used for either single queries or stateless multi-turn
|
304
|
-
# conversations.
|
305
|
-
#
|
306
|
-
# Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
|
307
583
|
sig do
|
308
584
|
params(
|
309
585
|
max_tokens: Integer,
|
@@ -332,6 +608,8 @@ module Anthropic
|
|
332
608
|
Anthropic::Tool::OrHash,
|
333
609
|
Anthropic::ToolBash20250124::OrHash,
|
334
610
|
Anthropic::ToolTextEditor20250124::OrHash,
|
611
|
+
Anthropic::ToolTextEditor20250429::OrHash,
|
612
|
+
Anthropic::ToolTextEditor20250728::OrHash,
|
335
613
|
Anthropic::WebSearchTool20250305::OrHash
|
336
614
|
)
|
337
615
|
],
|
@@ -411,37 +689,14 @@ module Anthropic
|
|
411
689
|
# { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
412
690
|
# ```
|
413
691
|
#
|
414
|
-
#
|
415
|
-
#
|
416
|
-
# ```json
|
417
|
-
# {
|
418
|
-
# "role": "user",
|
419
|
-
# "content": [
|
420
|
-
# {
|
421
|
-
# "type": "image",
|
422
|
-
# "source": {
|
423
|
-
# "type": "base64",
|
424
|
-
# "media_type": "image/jpeg",
|
425
|
-
# "data": "/9j/4AAQSkZJRg..."
|
426
|
-
# }
|
427
|
-
# },
|
428
|
-
# { "type": "text", "text": "What is in this image?" }
|
429
|
-
# ]
|
430
|
-
# }
|
431
|
-
# ```
|
432
|
-
#
|
433
|
-
# We currently support the `base64` source type for images, and the `image/jpeg`,
|
434
|
-
# `image/png`, `image/gif`, and `image/webp` media types.
|
435
|
-
#
|
436
|
-
# See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
437
|
-
# more input examples.
|
692
|
+
# See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
438
693
|
#
|
439
694
|
# Note that if you want to include a
|
440
695
|
# [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
441
696
|
# the top-level `system` parameter — there is no `"system"` role for input
|
442
697
|
# messages in the Messages API.
|
443
698
|
#
|
444
|
-
# There is a limit of
|
699
|
+
# There is a limit of 100,000 messages in a single request.
|
445
700
|
messages:,
|
446
701
|
# The model that will complete your prompt.\n\nSee
|
447
702
|
# [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
@@ -500,6 +755,12 @@ module Anthropic
|
|
500
755
|
# those tools using the tool input generated by the model and then optionally
|
501
756
|
# return results back to the model using `tool_result` content blocks.
|
502
757
|
#
|
758
|
+
# There are two types of tools: **client tools** and **server tools**. The
|
759
|
+
# behavior described below applies to client tools. For
|
760
|
+
# [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
|
761
|
+
# see their individual documentation as each has its own behavior (e.g., the
|
762
|
+
# [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
|
763
|
+
#
|
503
764
|
# Each tool definition includes:
|
504
765
|
#
|
505
766
|
# - `name`: Name of the tool.
|
@@ -618,6 +879,8 @@ module Anthropic
|
|
618
879
|
Anthropic::Tool::OrHash,
|
619
880
|
Anthropic::ToolBash20250124::OrHash,
|
620
881
|
Anthropic::ToolTextEditor20250124::OrHash,
|
882
|
+
Anthropic::ToolTextEditor20250429::OrHash,
|
883
|
+
Anthropic::ToolTextEditor20250728::OrHash,
|
621
884
|
Anthropic::WebSearchTool20250305::OrHash
|
622
885
|
)
|
623
886
|
],
|
@@ -682,37 +945,14 @@ module Anthropic
|
|
682
945
|
# { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
|
683
946
|
# ```
|
684
947
|
#
|
685
|
-
#
|
686
|
-
#
|
687
|
-
# ```json
|
688
|
-
# {
|
689
|
-
# "role": "user",
|
690
|
-
# "content": [
|
691
|
-
# {
|
692
|
-
# "type": "image",
|
693
|
-
# "source": {
|
694
|
-
# "type": "base64",
|
695
|
-
# "media_type": "image/jpeg",
|
696
|
-
# "data": "/9j/4AAQSkZJRg..."
|
697
|
-
# }
|
698
|
-
# },
|
699
|
-
# { "type": "text", "text": "What is in this image?" }
|
700
|
-
# ]
|
701
|
-
# }
|
702
|
-
# ```
|
703
|
-
#
|
704
|
-
# We currently support the `base64` source type for images, and the `image/jpeg`,
|
705
|
-
# `image/png`, `image/gif`, and `image/webp` media types.
|
706
|
-
#
|
707
|
-
# See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
|
708
|
-
# more input examples.
|
948
|
+
# See [input examples](https://docs.anthropic.com/en/api/messages-examples).
|
709
949
|
#
|
710
950
|
# Note that if you want to include a
|
711
951
|
# [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
|
712
952
|
# the top-level `system` parameter — there is no `"system"` role for input
|
713
953
|
# messages in the Messages API.
|
714
954
|
#
|
715
|
-
# There is a limit of
|
955
|
+
# There is a limit of 100,000 messages in a single request.
|
716
956
|
messages:,
|
717
957
|
# The model that will complete your prompt.\n\nSee
|
718
958
|
# [models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
@@ -744,6 +984,12 @@ module Anthropic
|
|
744
984
|
# those tools using the tool input generated by the model and then optionally
|
745
985
|
# return results back to the model using `tool_result` content blocks.
|
746
986
|
#
|
987
|
+
# There are two types of tools: **client tools** and **server tools**. The
|
988
|
+
# behavior described below applies to client tools. For
|
989
|
+
# [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
|
990
|
+
# see their individual documentation as each has its own behavior (e.g., the
|
991
|
+
# [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
|
992
|
+
#
|
747
993
|
# Each tool definition includes:
|
748
994
|
#
|
749
995
|
# - `name`: Name of the tool.
|
data/sig/anthropic/errors.rbs
CHANGED
@@ -5,6 +5,15 @@ module Anthropic
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class ConversionError < Anthropic::Errors::Error
|
8
|
+
def cause: -> StandardError?
|
9
|
+
|
10
|
+
def initialize: (
|
11
|
+
on: Class,
|
12
|
+
method: Symbol,
|
13
|
+
target: top,
|
14
|
+
value: top,
|
15
|
+
?cause: StandardError?
|
16
|
+
) -> void
|
8
17
|
end
|
9
18
|
|
10
19
|
class APIError < Anthropic::Errors::Error
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module Anthropic
|
2
|
+
module Helpers
|
3
|
+
module Streaming
|
4
|
+
type text_event = { type: :text, text: String, snapshot: String }
|
5
|
+
|
6
|
+
class TextEvent < Anthropic::Internal::Type::BaseModel
|
7
|
+
attr_accessor type: :text
|
8
|
+
|
9
|
+
attr_accessor text: String
|
10
|
+
|
11
|
+
attr_accessor snapshot: String
|
12
|
+
|
13
|
+
def initialize: (text: String, snapshot: String, ?type: :text) -> void
|
14
|
+
end
|
15
|
+
|
16
|
+
type citation_event =
|
17
|
+
{
|
18
|
+
type: :citation,
|
19
|
+
citation: Anthropic::Models::CitationsDelta::citation,
|
20
|
+
snapshot: ::Array[Anthropic::Models::CitationsDelta::citation]
|
21
|
+
}
|
22
|
+
|
23
|
+
class CitationEvent < Anthropic::Internal::Type::BaseModel
|
24
|
+
attr_accessor type: :citation
|
25
|
+
|
26
|
+
attr_accessor citation: Anthropic::Models::CitationsDelta::citation
|
27
|
+
|
28
|
+
attr_accessor snapshot: ::Array[Anthropic::Models::CitationsDelta::citation]
|
29
|
+
|
30
|
+
def initialize: (
|
31
|
+
citation: Anthropic::Models::CitationsDelta::citation,
|
32
|
+
snapshot: ::Array[Anthropic::Models::CitationsDelta::citation],
|
33
|
+
?type: :citation
|
34
|
+
) -> void
|
35
|
+
end
|
36
|
+
|
37
|
+
type thinking_event =
|
38
|
+
{ type: :thinking, thinking: String, snapshot: String }
|
39
|
+
|
40
|
+
class ThinkingEvent < Anthropic::Internal::Type::BaseModel
|
41
|
+
attr_accessor type: :thinking
|
42
|
+
|
43
|
+
attr_accessor thinking: String
|
44
|
+
|
45
|
+
attr_accessor snapshot: String
|
46
|
+
|
47
|
+
def initialize: (
|
48
|
+
thinking: String,
|
49
|
+
snapshot: String,
|
50
|
+
?type: :thinking
|
51
|
+
) -> void
|
52
|
+
end
|
53
|
+
|
54
|
+
type signature_event = { type: :signature, signature: String }
|
55
|
+
|
56
|
+
class SignatureEvent < Anthropic::Internal::Type::BaseModel
|
57
|
+
attr_accessor type: :signature
|
58
|
+
|
59
|
+
attr_accessor signature: String
|
60
|
+
|
61
|
+
def initialize: (signature: String, ?type: :signature) -> void
|
62
|
+
end
|
63
|
+
|
64
|
+
type input_json_event =
|
65
|
+
{ type: :input_json, partial_json: String, snapshot: untyped }
|
66
|
+
|
67
|
+
class InputJsonEvent < Anthropic::Internal::Type::BaseModel
|
68
|
+
attr_accessor type: :input_json
|
69
|
+
|
70
|
+
attr_accessor partial_json: String
|
71
|
+
|
72
|
+
attr_accessor snapshot: untyped
|
73
|
+
|
74
|
+
def initialize: (
|
75
|
+
partial_json: String,
|
76
|
+
snapshot: untyped,
|
77
|
+
?type: :input_json
|
78
|
+
) -> void
|
79
|
+
end
|
80
|
+
|
81
|
+
type message_stop_event =
|
82
|
+
{ type: :message_stop, message: Anthropic::Models::message }
|
83
|
+
|
84
|
+
class MessageStopEvent < Anthropic::Models::RawMessageStopEvent
|
85
|
+
attr_accessor type: :message_stop
|
86
|
+
|
87
|
+
attr_accessor message: Anthropic::Models::message
|
88
|
+
|
89
|
+
def initialize: (
|
90
|
+
message: Anthropic::Models::message,
|
91
|
+
?type: :message_stop
|
92
|
+
) -> void
|
93
|
+
end
|
94
|
+
|
95
|
+
type content_block_stop_event =
|
96
|
+
{
|
97
|
+
type: :content_block_stop,
|
98
|
+
index: Integer,
|
99
|
+
content_block: Anthropic::Models::content_block
|
100
|
+
}
|
101
|
+
|
102
|
+
class ContentBlockStopEvent < Anthropic::Models::RawContentBlockStopEvent
|
103
|
+
attr_accessor type: :content_block_stop
|
104
|
+
|
105
|
+
attr_accessor index: Integer
|
106
|
+
|
107
|
+
attr_accessor content_block: Anthropic::Models::content_block
|
108
|
+
|
109
|
+
def initialize: (
|
110
|
+
index: Integer,
|
111
|
+
content_block: Anthropic::Models::content_block,
|
112
|
+
?type: :content_block_stop
|
113
|
+
) -> void
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Anthropic
|
2
|
+
module Helpers
|
3
|
+
module Streaming
|
4
|
+
type raw_message_event =
|
5
|
+
Anthropic::Models::raw_message_start_event
|
6
|
+
| Anthropic::Models::raw_message_delta_event
|
7
|
+
| Anthropic::Models::raw_message_stop_event
|
8
|
+
| Anthropic::Models::raw_content_block_start_event
|
9
|
+
| Anthropic::Models::raw_content_block_delta_event
|
10
|
+
| Anthropic::Models::raw_content_block_stop_event
|
11
|
+
|
12
|
+
type stream_event =
|
13
|
+
raw_message_event
|
14
|
+
| text_event
|
15
|
+
| citation_event
|
16
|
+
| thinking_event
|
17
|
+
| signature_event
|
18
|
+
| input_json_event
|
19
|
+
| message_stop_event
|
20
|
+
| content_block_stop_event
|
21
|
+
|
22
|
+
class MessageStream
|
23
|
+
include Anthropic::Internal::Type::BaseStream[raw_message_event, stream_event]
|
24
|
+
|
25
|
+
@raw_stream: Anthropic::Internal::Stream[raw_message_event]
|
26
|
+
@accumated_message_snapshot: Anthropic::Models::message?
|
27
|
+
@iterator: Enumerable[stream_event]?
|
28
|
+
|
29
|
+
def initialize: (
|
30
|
+
raw_stream: Anthropic::Internal::Stream[raw_message_event]
|
31
|
+
) -> void
|
32
|
+
|
33
|
+
def until_done: -> void
|
34
|
+
|
35
|
+
def text: -> Enumerator[String]
|
36
|
+
|
37
|
+
def accumulated_message: -> Anthropic::Models::message
|
38
|
+
|
39
|
+
def accumulated_text: -> String
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def iterator: -> Enumerable[stream_event]
|
44
|
+
|
45
|
+
def accumulate_event: (
|
46
|
+
event: raw_message_event,
|
47
|
+
current_snapshot: Anthropic::Models::message?
|
48
|
+
) -> Anthropic::Models::message
|
49
|
+
|
50
|
+
def build_events: (
|
51
|
+
event: raw_message_event,
|
52
|
+
message_snapshot: Anthropic::Models::message
|
53
|
+
) -> ::Array[stream_event]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|