claude-ruby 0.4.1 → 0.4.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 +4 -4
- data/CHANGELOG.md +10 -1
- data/Gemfile.lock +6 -4
- data/README.md +14 -23
- data/lib/claude/client.rb +22 -8
- data/lib/claude/ruby/version.rb +1 -1
- data/sig/claude/client.rbs +0 -1
- metadata +19 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b84b1d8c31e49380d6474c7cf30f581b51846158095feb37723e81470fa64ad3
|
|
4
|
+
data.tar.gz: fca20c7c2d90146cfe649c2e39fa77596d711805b9a4c84a83acc96d9e582fbf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1fa9f80289403fa0ca5112a51b646d96f162249c9b18c6e3cc32882469f6e7b76873e446deadf0149d6f638e751b1e36cedb3f6ac93961652bfbb24541d34ffd
|
|
7
|
+
data.tar.gz: 263f6b26c84aaaf8a28de3785cf5a62d762de5aecc04b17642258dbf1f1ca49e35ec8f99ac5b72e29f3b31f622fff1a33dcab7188179d64c2d0c2822575f0ee3
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
## [0.4.3] - 2026-12-04
|
|
2
|
+
- Corrected the deprecation notices to name the official `anthropic` gem and marked this client as deprecated in its RubyGems summary.
|
|
3
|
+
- Disabled redirects on authenticated requests, restricted response parsing to JSON, and hid the API key from client inspection.
|
|
4
|
+
- Reject custom endpoint options that earlier versions silently ignored. The default Anthropic endpoint is unchanged.
|
|
5
|
+
- Raised the minimum HTTParty version to 0.24.0.
|
|
6
|
+
|
|
7
|
+
## [0.4.2] - 2026-01-19
|
|
8
|
+
- Added deprecation warning
|
|
9
|
+
|
|
1
10
|
## [0.4.1] - 2024-11-06
|
|
2
11
|
- Added the latest Claude models
|
|
3
|
-
|
|
12
|
+
|
|
4
13
|
## [0.4.0] - 2024-07-09
|
|
5
14
|
- Refactored model constants into a separate Model module
|
|
6
15
|
- Support custom endpoints
|
data/Gemfile.lock
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
claude-ruby (0.4.
|
|
5
|
-
httparty
|
|
4
|
+
claude-ruby (0.4.3)
|
|
5
|
+
httparty (>= 0.24.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
10
|
ast (2.4.2)
|
|
11
|
+
csv (3.3.7)
|
|
11
12
|
docile (1.4.0)
|
|
12
|
-
httparty (0.
|
|
13
|
+
httparty (0.25.1)
|
|
14
|
+
csv
|
|
13
15
|
mini_mime (>= 1.0.0)
|
|
14
16
|
multi_xml (>= 0.5.2)
|
|
15
17
|
json (2.7.1)
|
|
@@ -25,7 +27,7 @@ GEM
|
|
|
25
27
|
rainbow (3.1.1)
|
|
26
28
|
rake (13.1.0)
|
|
27
29
|
regexp_parser (2.9.0)
|
|
28
|
-
rexml (3.
|
|
30
|
+
rexml (3.4.4)
|
|
29
31
|
rubocop (1.62.0)
|
|
30
32
|
json (~> 2.3)
|
|
31
33
|
language_server-protocol (>= 3.17.0)
|
data/README.md
CHANGED
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
# Claude Ruby
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!CAUTION]
|
|
4
|
+
> **This gem is deprecated and no longer maintained.**
|
|
5
|
+
>
|
|
6
|
+
> For new development, use Anthropic's official [`anthropic` gem](https://rubygems.org/gems/anthropic).
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
---
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
[](https://badge.fury.io/rb/claude-ruby) [](https://opensource.org/licenses/MIT) [](https://github.com/webventures/claude-ruby/actions/workflows/ci.yml)
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
`claude-ruby` gem is an unofficial ruby SDK for interacting with the Anthropic API, for generating and streaming messages through Claude
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
gem 'claude-ruby'
|
|
13
|
-
```
|
|
14
|
+
## Migrating to the official SDK
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
Install it with `gem install anthropic` or use this entry in your Gemfile.
|
|
16
17
|
|
|
17
18
|
```ruby
|
|
18
|
-
|
|
19
|
+
gem 'anthropic'
|
|
19
20
|
```
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
Existing applications also need to update their client calls. The official SDK uses `require 'anthropic'` and `Anthropic::Client`. See [Anthropic's Ruby SDK examples](https://github.com/anthropics/anthropic-sdk-ruby#getting-started).
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
$ gem install claude-ruby
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
24
|
+
## Legacy client usage
|
|
28
25
|
|
|
29
26
|
To use this gem you'll need an API key from Anthropic, which can be obtained from the Anthropic console
|
|
30
27
|
by following the Get API Access link on the [Anthropic API page](https://www.anthropic.com/api).
|
|
@@ -210,13 +207,7 @@ response = claude_client.messages(messages,
|
|
|
210
207
|
|
|
211
208
|
## Custom endpoint
|
|
212
209
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
You can optionally optionally override this - e.g. for testing, or for using a beta endpoint.
|
|
216
|
-
|
|
217
|
-
```ruby
|
|
218
|
-
claude_client = Claude::Client.new(api_key, endpoint: 'your-custom-endpoint')
|
|
219
|
-
```
|
|
210
|
+
The legacy client sends requests to `https://api.anthropic.com/v1/messages`. Earlier versions accepted a custom `endpoint:` option but still sent requests to Anthropic. Version 0.4.3 raises an error when given a different endpoint, before sending a request.
|
|
220
211
|
|
|
221
212
|
## Vision
|
|
222
213
|
|
|
@@ -280,4 +271,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
280
271
|
## Trademarks
|
|
281
272
|
|
|
282
273
|
This is an unofficial gem which has not been developed by Anthropic.
|
|
283
|
-
We make no claims for the trademarks of 'Anthropic' and 'Claude', which are registered by Anthropic PBC.
|
|
274
|
+
We make no claims for the trademarks of 'Anthropic' and 'Claude', which are registered by Anthropic PBC.
|
data/lib/claude/client.rb
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
require 'httparty'
|
|
2
2
|
require 'json'
|
|
3
3
|
|
|
4
|
+
warn <<~DEPRECATION
|
|
5
|
+
[DEPRECATION WARNING] The 'claude-ruby' gem is deprecated and no longer maintained.
|
|
6
|
+
Please switch to the official Anthropic Ruby SDK: gem install anthropic
|
|
7
|
+
More info: https://github.com/anthropics/anthropic-sdk-ruby
|
|
8
|
+
DEPRECATION
|
|
9
|
+
|
|
4
10
|
module Claude
|
|
5
11
|
module Model
|
|
6
12
|
CLAUDE_3_OPUS_20240229 = 'claude-3-opus-20240229'
|
|
@@ -19,7 +25,7 @@ module Claude
|
|
|
19
25
|
CLAUDE_FASTEST = CLAUDE_HAIKU_LATEST
|
|
20
26
|
CLAUDE_CHEAPEST = CLAUDE_3_HAIKU_20240307
|
|
21
27
|
CLAUDE_BALANCED = CLAUDE_SONNET_LATEST
|
|
22
|
-
CLAUDE_SMARTEST =
|
|
28
|
+
CLAUDE_SMARTEST = CLAUDE_3_5_SONNET_20241022
|
|
23
29
|
|
|
24
30
|
CLAUDE_DEFAULT = CLAUDE_BALANCED
|
|
25
31
|
end
|
|
@@ -28,10 +34,17 @@ module Claude
|
|
|
28
34
|
|
|
29
35
|
def initialize(api_key, endpoint: nil, timeout: 60)
|
|
30
36
|
@api_key = api_key
|
|
31
|
-
@endpoint = endpoint || anthropic_endpoint
|
|
32
37
|
@timeout = timeout
|
|
33
38
|
|
|
34
39
|
raise(ArgumentError, "api_key is required") if api_key.nil?
|
|
40
|
+
|
|
41
|
+
unless endpoint.nil? || [anthropic_endpoint, messages_endpoint].include?(endpoint.to_s.delete_suffix('/'))
|
|
42
|
+
raise ArgumentError, "Custom endpoints are unsupported. Use the official anthropic gem for a custom endpoint."
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def inspect
|
|
47
|
+
"#<#{self.class}>"
|
|
35
48
|
end
|
|
36
49
|
|
|
37
50
|
def version
|
|
@@ -107,12 +120,13 @@ module Claude
|
|
|
107
120
|
private
|
|
108
121
|
|
|
109
122
|
def post_api(url, data, timeout)
|
|
110
|
-
response = HTTParty.post(url, body: data.to_json, headers: headers, timeout: timeout)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
response = HTTParty.post(url, body: data.to_json, headers: headers, timeout: timeout, follow_redirects: false)
|
|
124
|
+
raise "Refusing HTTP redirect (#{response.code}) from the Anthropic API" if (300..399).cover?(response.code)
|
|
125
|
+
|
|
126
|
+
payload = JSON.parse(response.body)
|
|
127
|
+
raise "#{payload['error']['type']}: #{payload['error']['message']}" if payload.is_a?(Hash) && payload['type'] == 'error'
|
|
128
|
+
|
|
129
|
+
payload
|
|
116
130
|
end
|
|
117
131
|
end
|
|
118
132
|
end
|
data/lib/claude/ruby/version.rb
CHANGED
data/sig/claude/client.rbs
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: claude-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Web Ventures Ltd
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: httparty
|
|
@@ -16,18 +15,18 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: 0.24.0
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
27
|
-
description: Ruby
|
|
28
|
-
|
|
25
|
+
version: 0.24.0
|
|
26
|
+
description: This unofficial Ruby client for the Anthropic API is retired. For new
|
|
27
|
+
development, install the 'anthropic' gem.
|
|
29
28
|
email:
|
|
30
|
-
-
|
|
29
|
+
- gems@dev.webven.nz
|
|
31
30
|
executables: []
|
|
32
31
|
extensions: []
|
|
33
32
|
extra_rdoc_files: []
|
|
@@ -50,7 +49,15 @@ metadata:
|
|
|
50
49
|
homepage_uri: https://github.com/webventures/claude-ruby.git
|
|
51
50
|
source_code_uri: https://github.com/webventures/claude-ruby.git
|
|
52
51
|
changelog_uri: https://github.com/webventures/claude-ruby/blob/main/CHANGELOG.md
|
|
53
|
-
post_install_message:
|
|
52
|
+
post_install_message: |
|
|
53
|
+
======================================================================
|
|
54
|
+
DEPRECATION NOTICE: The 'claude-ruby' gem is deprecated.
|
|
55
|
+
|
|
56
|
+
Anthropic now provides an official Ruby SDK. Please migrate to:
|
|
57
|
+
gem install anthropic
|
|
58
|
+
|
|
59
|
+
More info: https://github.com/anthropics/anthropic-sdk-ruby
|
|
60
|
+
======================================================================
|
|
54
61
|
rdoc_options: []
|
|
55
62
|
require_paths:
|
|
56
63
|
- lib
|
|
@@ -65,8 +72,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
65
72
|
- !ruby/object:Gem::Version
|
|
66
73
|
version: '0'
|
|
67
74
|
requirements: []
|
|
68
|
-
rubygems_version: 3.
|
|
69
|
-
signing_key:
|
|
75
|
+
rubygems_version: 3.6.9
|
|
70
76
|
specification_version: 4
|
|
71
|
-
summary:
|
|
77
|
+
summary: Deprecated unofficial Claude client. Use Anthropic's official 'anthropic'
|
|
78
|
+
gem.
|
|
72
79
|
test_files: []
|