claude-ruby 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +78 -0
- data/README.md +5 -5
- data/lib/claude/client.rb +7 -8
- data/lib/claude/ruby/version.rb +1 -1
- metadata +8 -13
- data/.idea/.gitignore +0 -8
- data/.idea/claude-ruby.iml +0 -23
- data/.idea/misc.xml +0 -4
- data/.idea/modules.xml +0 -8
- data/.idea/vcs.xml +0 -6
- data/.rubocop.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46caaa462835cb7b1cfff4ca13ad00a59236873211a96871d79c7c420f3945c3
|
4
|
+
data.tar.gz: e945c6ce9c036eccb7733c361fcc842b4143496577a21e2c3ff9ce055bd15873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be6c578a3b72aa328c9cf6416a7e8ac63d734202fc790797f819ea993e35daf09c63cee950c6351d2f4de5319a9a59614eb66c4c51c8821543609526278fde1a
|
7
|
+
data.tar.gz: 908b61f2a4aa9e5295c6ca322ffc6b97eca682c519d85c5bbc433a50843e329474ec04e924f034345677758fced4d23fa28c7c7f8eeb8dbbe4e4b5c071d463ec
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
claude-ruby (0.2.0)
|
5
|
+
rest-client
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
docile (1.4.0)
|
12
|
+
domain_name (0.6.20240107)
|
13
|
+
http-accept (1.7.0)
|
14
|
+
http-cookie (1.0.5)
|
15
|
+
domain_name (~> 0.5)
|
16
|
+
httparty (0.21.0)
|
17
|
+
mini_mime (>= 1.0.0)
|
18
|
+
multi_xml (>= 0.5.2)
|
19
|
+
json (2.7.1)
|
20
|
+
language_server-protocol (3.17.0.3)
|
21
|
+
mime-types (3.5.2)
|
22
|
+
mime-types-data (~> 3.2015)
|
23
|
+
mime-types-data (3.2024.0305)
|
24
|
+
mini_mime (1.1.5)
|
25
|
+
minitest (5.22.2)
|
26
|
+
multi_xml (0.6.0)
|
27
|
+
netrc (0.11.0)
|
28
|
+
parallel (1.24.0)
|
29
|
+
parser (3.3.0.5)
|
30
|
+
ast (~> 2.4.1)
|
31
|
+
racc
|
32
|
+
racc (1.7.3)
|
33
|
+
rainbow (3.1.1)
|
34
|
+
rake (13.1.0)
|
35
|
+
regexp_parser (2.9.0)
|
36
|
+
rest-client (2.1.0)
|
37
|
+
http-accept (>= 1.7.0, < 2.0)
|
38
|
+
http-cookie (>= 1.0.2, < 2.0)
|
39
|
+
mime-types (>= 1.16, < 4.0)
|
40
|
+
netrc (~> 0.8)
|
41
|
+
rexml (3.2.6)
|
42
|
+
rubocop (1.62.0)
|
43
|
+
json (~> 2.3)
|
44
|
+
language_server-protocol (>= 3.17.0)
|
45
|
+
parallel (~> 1.10)
|
46
|
+
parser (>= 3.3.0.2)
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
49
|
+
rexml (>= 3.2.5, < 4.0)
|
50
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
51
|
+
ruby-progressbar (~> 1.7)
|
52
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
53
|
+
rubocop-ast (1.31.2)
|
54
|
+
parser (>= 3.3.0.4)
|
55
|
+
ruby-progressbar (1.13.0)
|
56
|
+
simplecov (0.22.0)
|
57
|
+
docile (~> 1.1)
|
58
|
+
simplecov-html (~> 0.11)
|
59
|
+
simplecov_json_formatter (~> 0.1)
|
60
|
+
simplecov-html (0.12.3)
|
61
|
+
simplecov_json_formatter (0.1.4)
|
62
|
+
unicode-display_width (2.5.0)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
arm64-darwin-22
|
66
|
+
ruby
|
67
|
+
|
68
|
+
DEPENDENCIES
|
69
|
+
claude-ruby!
|
70
|
+
httparty
|
71
|
+
minitest (~> 5.0)
|
72
|
+
rake (~> 13.0)
|
73
|
+
rubocop (~> 1.21)
|
74
|
+
simplecov
|
75
|
+
simplecov_json_formatter
|
76
|
+
|
77
|
+
BUNDLED WITH
|
78
|
+
2.5.3
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Claude Ruby
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/claude-ruby.svg)](https://badge.fury.io/rb/claude-ruby) [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Maintainability](https://api.codeclimate.com/v1/badges/08c7e7b58e9fbe7156eb/maintainability)](https://codeclimate.com/github/
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/claude-ruby.svg)](https://badge.fury.io/rb/claude-ruby) [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Maintainability](https://api.codeclimate.com/v1/badges/08c7e7b58e9fbe7156eb/maintainability)](https://codeclimate.com/github/webventures/claude-ruby/maintainability) [![CI](https://github.com/webventures/claude-ruby/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/webventures/claude-ruby/actions/workflows/ci.yml)
|
4
4
|
|
5
5
|
`claude-ruby` gem is an unofficial ruby SDK for interacting with the Anthropic API, for generating and streaming messages through Claude
|
6
6
|
|
@@ -26,15 +26,15 @@ $ gem install claude-ruby
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
To use this
|
30
|
-
by following the Get API Access link on the [
|
29
|
+
To use this gem you'll need an API key from Anthropic, which can be obtained from the Anthropic console
|
30
|
+
by following the Get API Access link on the [Anthropic API page](https://www.anthropic.com/api).
|
31
31
|
|
32
32
|
Set your API key as an environment variable then you can create a new `Claude::Client` instance:
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
require 'claude/client'
|
36
36
|
|
37
|
-
api_key = ENV['
|
37
|
+
api_key = ENV['YOUR_ANTHROPIC_API_KEY']
|
38
38
|
claude_client = Claude::Client.new(api_key)
|
39
39
|
```
|
40
40
|
|
@@ -125,7 +125,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
125
125
|
|
126
126
|
## Contributing
|
127
127
|
|
128
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
128
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/webventures/claude-ruby.
|
129
129
|
|
130
130
|
## License
|
131
131
|
|
data/lib/claude/client.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'httparty'
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module Claude
|
@@ -28,7 +28,7 @@ module Claude
|
|
28
28
|
top_k: params[:top_k],
|
29
29
|
}.compact
|
30
30
|
|
31
|
-
|
31
|
+
post_api(url, data)
|
32
32
|
end
|
33
33
|
|
34
34
|
def headers
|
@@ -41,13 +41,12 @@ module Claude
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
44
|
+
def post_api(url, data)
|
45
|
+
response = HTTParty.post(url, body: data.to_json, headers: headers)
|
46
|
+
if response && response['type'] == 'error'
|
47
|
+
raise StandardError.new("#{response['error']['type']}: #{response['error']['message']}")
|
48
|
+
else
|
47
49
|
JSON.parse(response.body)
|
48
|
-
rescue RestClient::ExceptionWithResponse => e
|
49
|
-
error_msg = JSON.parse(e.response.body)['error']['message']
|
50
|
-
raise RestClient::ExceptionWithResponse.new("#{e.message}: #{error_msg} (#{e.http_code})"), nil, e.backtrace
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
data/lib/claude/ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claude-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Web Ventures Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -32,14 +32,9 @@ executables: []
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
-
- ".idea/.gitignore"
|
36
|
-
- ".idea/claude-ruby.iml"
|
37
|
-
- ".idea/misc.xml"
|
38
|
-
- ".idea/modules.xml"
|
39
|
-
- ".idea/vcs.xml"
|
40
|
-
- ".rubocop.yml"
|
41
35
|
- CHANGELOG.md
|
42
36
|
- Gemfile
|
37
|
+
- Gemfile.lock
|
43
38
|
- LICENSE.txt
|
44
39
|
- README.md
|
45
40
|
- Rakefile
|
@@ -47,13 +42,13 @@ files:
|
|
47
42
|
- lib/claude/ruby.rb
|
48
43
|
- lib/claude/ruby/version.rb
|
49
44
|
- sig/claude/ruby.rbs
|
50
|
-
homepage: https://github.com/
|
45
|
+
homepage: https://github.com/webventures/claude-ruby.git
|
51
46
|
licenses:
|
52
47
|
- MIT
|
53
48
|
metadata:
|
54
|
-
homepage_uri: https://github.com/
|
55
|
-
source_code_uri: https://github.com/
|
56
|
-
changelog_uri: https://github.com/
|
49
|
+
homepage_uri: https://github.com/webventures/claude-ruby.git
|
50
|
+
source_code_uri: https://github.com/webventures/claude-ruby.git
|
51
|
+
changelog_uri: https://github.com/webventures/claude-ruby/blob/main/CHANGELOG.md
|
57
52
|
post_install_message:
|
58
53
|
rdoc_options: []
|
59
54
|
require_paths:
|
@@ -62,7 +57,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
57
|
requirements:
|
63
58
|
- - ">="
|
64
59
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
60
|
+
version: 3.0.0
|
66
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
62
|
requirements:
|
68
63
|
- - ">="
|
data/.idea/.gitignore
DELETED
data/.idea/claude-ruby.iml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
4
|
-
<shared />
|
5
|
-
</component>
|
6
|
-
<component name="NewModuleRootManager">
|
7
|
-
<content url="file://$MODULE_DIR$">
|
8
|
-
<sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
|
9
|
-
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
10
|
-
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
11
|
-
</content>
|
12
|
-
<orderEntry type="inheritedJdk" />
|
13
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.1.4, rbenv: 2.6.8) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, rbenv: 2.6.8) [gem]" level="application" />
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 2.6.8) [gem]" level="application" />
|
17
|
-
</component>
|
18
|
-
<component name="RakeTasksCache">
|
19
|
-
<option name="myRootTask">
|
20
|
-
<RakeTaskImpl id="rake" />
|
21
|
-
</option>
|
22
|
-
</component>
|
23
|
-
</module>
|
data/.idea/misc.xml
DELETED
data/.idea/modules.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/claude-ruby.iml" filepath="$PROJECT_DIR$/.idea/claude-ruby.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
8
|
-
</project>
|
data/.idea/vcs.xml
DELETED
data/.rubocop.yml
DELETED