diff --git a/README.md b/README.md index 7b27bc2..a17a786 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ end # Hello! Not much up with me, I'm an AI assistant created by Anthropic. ``` -You can also experiment with the new tools beta by passing the `beta` name when calling the API. This will ensure each request includes the correct beta header and validate properly. +You can also pass in a list of tools the assistant can use. You can find out more information about tools in the [documentation](https://docs.anthropic.com/claude/docs/tool-use). ```ruby tools = [ @@ -107,7 +107,7 @@ tools = [ } ] -Anthropic.messages(beta: 'tools-2024-04-04').create( +Anthropic.messages.create( model: 'claude-3-opus-20240229', max_tokens: 200, tools:, @@ -115,8 +115,6 @@ Anthropic.messages(beta: 'tools-2024-04-04').create( ) ``` -Streaming is currently not supported by the tools beta. You can find out more information about tools in the [documentation](https://docs.anthropic.com/claude/docs/tool-use). - ### Completions API To make a request to the Completions API: diff --git a/lib/anthropic/api/base.rb b/lib/anthropic/api/base.rb index 3a7c5f6..1d561d3 100644 --- a/lib/anthropic/api/base.rb +++ b/lib/anthropic/api/base.rb @@ -17,9 +17,6 @@ class SchemaValidationError < StandardError; end # Error for when the API version is not supported. class UnsupportedApiVersionError < StandardError; end - # Error for when a beta feature is not used correctly. - class UnsupportedBetaUseError < StandardError; end - # Error for when the provided beta is not supported. class UnsupportedBetaError < StandardError; end diff --git a/lib/anthropic/api/messages.rb b/lib/anthropic/api/messages.rb index 148804e..c956ad3 100644 --- a/lib/anthropic/api/messages.rb +++ b/lib/anthropic/api/messages.rb @@ -6,13 +6,8 @@ module Api # Provides bindings for the Anthropic messages API class Messages < Base def create(**params, &) - streaming = params[:stream] - if streaming && beta_loaded?('tools-2024-04-04') - raise Anthropic::Api::UnsupportedBetaUseError, 'Tool use is not yet supported in streaming mode' - end - validate!(params) - return post(params) unless streaming + return post(params) unless params[:stream] post_as_stream(params, &) end diff --git a/sanity_check.rb b/sanity_check.rb index c7ec660..4039786 100644 --- a/sanity_check.rb +++ b/sanity_check.rb @@ -21,7 +21,7 @@ stream: true ) { |event| puts event } -puts "\nTesting tools beta" +puts "\nTesting tools" tools = [ { name: 'get_weather', diff --git a/schemas/betas/tools-2024-04-04.json b/schemas/betas/tools-2024-04-04.json index 5dbf429..63f7be5 100644 --- a/schemas/betas/tools-2024-04-04.json +++ b/schemas/betas/tools-2024-04-04.json @@ -1,7 +1,7 @@ { "id": "tools-2024-04-04", - "name": "Tools", - "description": "Equips Claude with custom tools for interacting with clients for a wide variety of tasks.", + "name": "[Deprecated] Tools", + "description": "[Deprecated] Equips Claude with custom tools for interacting with clients for a wide variety of tasks.", "documentation": "https://docs.anthropic.com/claude/docs/tool-use", "header" : { "anthropic-beta": "tools-2024-04-04" }, "schema": { diff --git a/schemas/versions/messages/2023-06-01.json b/schemas/versions/messages/2023-06-01.json index e8a2fb6..bc464d6 100644 --- a/schemas/versions/messages/2023-06-01.json +++ b/schemas/versions/messages/2023-06-01.json @@ -30,6 +30,23 @@ "temperature": { "type": "number" }, + "tools": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "input_schema": { + "type": "object" + } + } + } + }, "top_k": { "type": "integer" }, diff --git a/spec/lib/anthropic/api/messages_spec.rb b/spec/lib/anthropic/api/messages_spec.rb index a52ee0b..51e663d 100644 --- a/spec/lib/anthropic/api/messages_spec.rb +++ b/spec/lib/anthropic/api/messages_spec.rb @@ -45,21 +45,6 @@ .to have_requested(:post, 'https://api.anthropic.com/v1/messages') .with(headers: { 'anthropic-beta' => 'tools-2024-04-04' }) end - - context 'when the request is for streaming' do # rubocop:disable RSpec/NestedGroups - let(:params) do - { - model: 'claude-2.1', - messages: [{ role: 'user', content: 'foo' }], - max_tokens: 200, - stream: true - } - end - - it 'raises an error' do - expect { call_method }.to raise_error(Anthropic::Api::UnsupportedBetaUseError) - end - end end context 'with valid params' do