claude-ruby 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b216c34d33d43142418a12fa080388398044f0552c2146b990a4d78d04f98d82
4
- data.tar.gz: 9f82ea13bea11b376aa10b058fba3d45afbc04100fe0fd103e7a6cbd8de5b46a
3
+ metadata.gz: 46caaa462835cb7b1cfff4ca13ad00a59236873211a96871d79c7c420f3945c3
4
+ data.tar.gz: e945c6ce9c036eccb7733c361fcc842b4143496577a21e2c3ff9ce055bd15873
5
5
  SHA512:
6
- metadata.gz: f774be056a44ab57dd6bab72f0dd7d98e9c25a76f52b7524809beeab003bd14ac400a9b93d8a67323e5902fc91be745131980925f074a47878e61b79727055db
7
- data.tar.gz: dcba4a5ff5c4472aa21222d20a37edc7558ae5d5b46abc332b4354844d93f1ff5c121e69766163bbb02f93fb8ca7a26e01da8ec7154fc1b6d533f8081f575f4b
6
+ metadata.gz: be6c578a3b72aa328c9cf6416a7e8ac63d734202fc790797f819ea993e35daf09c63cee950c6351d2f4de5319a9a59614eb66c4c51c8821543609526278fde1a
7
+ data.tar.gz: 908b61f2a4aa9e5295c6ca322ffc6b97eca682c519d85c5bbc433a50843e329474ec04e924f034345677758fced4d23fa28c7c7f8eeb8dbbe4e4b5c071d463ec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,3 @@
1
- ## [0.1.0] - 2024-0310-
1
+ ## [0.1.1] - 2024-03-10
2
2
 
3
3
  - Initial release
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ gem "minitest", "~> 5.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
13
 
14
- gem 'rest-client'
14
+ gem 'httparty'
15
15
 
16
16
  group :test do
17
17
  gem 'simplecov', require: false
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/webven/claude-ruby/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/08c7e7b58e9fbe7156eb/test_coverage)](https://codeclimate.com/github/webven/claude-ruby/test_coverage) [![CI](https://github.com/webven/claude-ruby/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/webven/claude-ruby/actions/workflows/ci.yml)
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 gemyou'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 [Anthrpic API page](https://www.anthropic.com/api).
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['YOUR_ANTROPIC_API_KEY']
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/webven/claude-ruby.
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 'rest-client'
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
- request_api(url, data)
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 request_api(url, data, method = :post)
45
- begin
46
- response = RestClient::Request.execute(method: method, url: url, payload: data.to_json, headers: headers)
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Claude
4
4
  module Ruby
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
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.1.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-10 00:00:00.000000000 Z
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/webven/claude-ruby.git
45
+ homepage: https://github.com/webventures/claude-ruby.git
51
46
  licenses:
52
47
  - MIT
53
48
  metadata:
54
- homepage_uri: https://github.com/webven/claude-ruby.git
55
- source_code_uri: https://github.com/webven/claude-ruby.git
56
- changelog_uri: https://github.com/webven/claude-ruby/blob/main/CHANGELOG.md
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: 2.6.0
60
+ version: 3.0.0
66
61
  required_rubygems_version: !ruby/object:Gem::Requirement
67
62
  requirements:
68
63
  - - ">="
data/.idea/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Editor-based HTTP Client requests
5
- /httpRequests/
6
- # Datasource local storage ignored files
7
- /dataSources/
8
- /dataSources.local.xml
@@ -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
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 2.6.8" project-jdk-type="RUBY_SDK" />
4
- </project>
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
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120