ruby-anthropic 0.4.2
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 +7 -0
- data/.circleci/config.yml +45 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/dependabot.yml +15 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +30 -0
- data/CHANGELOG.md +63 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +88 -0
- data/LICENSE.txt +21 -0
- data/README.md +413 -0
- data/Rakefile +19 -0
- data/anthropic.gemspec +31 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/anthropic/client.rb +113 -0
- data/lib/anthropic/compatibility.rb +10 -0
- data/lib/anthropic/http.rb +200 -0
- data/lib/anthropic/http_headers.rb +38 -0
- data/lib/anthropic/messages/batches.rb +112 -0
- data/lib/anthropic/messages/client.rb +13 -0
- data/lib/anthropic/version.rb +3 -0
- data/lib/anthropic.rb +72 -0
- data/lib/ruby/anthropic.rb +2 -0
- data/pull_request_template.md +5 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 667016d06b1fb0462201ba841a60cb725ea9c18043b8ea6cadb21540f938c15d
|
4
|
+
data.tar.gz: 6683b147ad50c69a1110a1b1505ff1b4ae69dc7c245cb8e4856cb5d4e7c64e8b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 809e06f23476a687777a203bac0ac550e28c6d5c6efcf40a36b9b61b2bf98df1d07169d344961a63725893b4e7635e75418812d54c910a782434c89d185515b9
|
7
|
+
data.tar.gz: 015212e6eb0c2da652bf7970fab3b3641b9456aac8f8345832bea8cb559730187da1dca0490508bdffbe4de89703d550017c8332ea861925ddcecb9be8179731
|
@@ -0,0 +1,45 @@
|
|
1
|
+
version: 2.1 # Use 2.1 to enable using orbs and other features.
|
2
|
+
|
3
|
+
# Declare the orbs that we'll use in our config.
|
4
|
+
orbs:
|
5
|
+
ruby: circleci/ruby@1.0
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
rubocop:
|
9
|
+
parallelism: 1
|
10
|
+
docker:
|
11
|
+
- image: cimg/ruby:3.1-node
|
12
|
+
steps:
|
13
|
+
- checkout
|
14
|
+
- ruby/install-deps
|
15
|
+
- run:
|
16
|
+
name: Run Rubocop
|
17
|
+
command: bundle exec rubocop
|
18
|
+
test:
|
19
|
+
parameters:
|
20
|
+
ruby-image:
|
21
|
+
type: string
|
22
|
+
parallelism: 1
|
23
|
+
docker:
|
24
|
+
- image: << parameters.ruby-image >>
|
25
|
+
steps:
|
26
|
+
- checkout
|
27
|
+
- ruby/install-deps
|
28
|
+
- run:
|
29
|
+
name: Run tests
|
30
|
+
command: bundle exec rspec -fd
|
31
|
+
|
32
|
+
workflows:
|
33
|
+
version: 2
|
34
|
+
checks:
|
35
|
+
jobs:
|
36
|
+
- rubocop
|
37
|
+
- test:
|
38
|
+
matrix:
|
39
|
+
parameters:
|
40
|
+
ruby-image:
|
41
|
+
- cimg/ruby:2.6-node
|
42
|
+
- cimg/ruby:2.7-node
|
43
|
+
- cimg/ruby:3.0-node
|
44
|
+
- cimg/ruby:3.1-node
|
45
|
+
- cimg/ruby:3.2-node
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Describe the bug**
|
11
|
+
A clear and concise description of what the bug is.
|
12
|
+
|
13
|
+
**To Reproduce**
|
14
|
+
Steps to reproduce the behavior:
|
15
|
+
1. Go to '...'
|
16
|
+
2. Click on '....'
|
17
|
+
3. Scroll down to '....'
|
18
|
+
4. See error
|
19
|
+
|
20
|
+
**Expected behavior**
|
21
|
+
A clear and concise description of what you expected to happen.
|
22
|
+
|
23
|
+
**Screenshots**
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
25
|
+
|
26
|
+
**Desktop (please complete the following information):**
|
27
|
+
- OS: [e.g. iOS]
|
28
|
+
- Browser [e.g. chrome, safari]
|
29
|
+
- Version [e.g. 22]
|
30
|
+
|
31
|
+
**Smartphone (please complete the following information):**
|
32
|
+
- Device: [e.g. iPhone6]
|
33
|
+
- OS: [e.g. iOS8.1]
|
34
|
+
- Browser [e.g. stock browser, safari]
|
35
|
+
- Version [e.g. 22]
|
36
|
+
|
37
|
+
**Additional context**
|
38
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
title: ''
|
5
|
+
labels: ''
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12
|
+
|
13
|
+
**Describe the solution you'd like**
|
14
|
+
A clear and concise description of what you want to happen.
|
15
|
+
|
16
|
+
**Describe alternatives you've considered**
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
18
|
+
|
19
|
+
**Additional context**
|
20
|
+
Add any other context or screenshots about the feature request here.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: bundler
|
4
|
+
directory: "/"
|
5
|
+
schedule:
|
6
|
+
interval: daily
|
7
|
+
open-pull-requests-limit: 10
|
8
|
+
ignore:
|
9
|
+
- dependency-name: webmock
|
10
|
+
versions:
|
11
|
+
- 3.11.1
|
12
|
+
- 3.11.3
|
13
|
+
- dependency-name: rspec
|
14
|
+
versions:
|
15
|
+
- 3.10.0
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
NewCops: enable
|
4
|
+
SuggestExtensions: false
|
5
|
+
|
6
|
+
Style/Documentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Layout/LineLength:
|
10
|
+
Max: 100
|
11
|
+
Exclude:
|
12
|
+
- "**/*.gemspec"
|
13
|
+
|
14
|
+
Metrics/AbcSize:
|
15
|
+
Max: 20
|
16
|
+
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Exclude:
|
19
|
+
- "spec/**/*"
|
20
|
+
|
21
|
+
Style/StringLiterals:
|
22
|
+
EnforcedStyle: double_quotes
|
23
|
+
|
24
|
+
Style/FrozenStringLiteralComment:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
# Disable Security/MarshalLoad rule only for spec files
|
28
|
+
Security/MarshalLoad:
|
29
|
+
Exclude:
|
30
|
+
- "spec/**/*"
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [0.4.2] - 2025-04-10
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Rename gem to `ruby-anthropic`!
|
13
|
+
- Remove deprecation warning.
|
14
|
+
|
15
|
+
## [0.4.1] - 2025-04-10
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Add deprecation warning - this gem will be renamed to ruby-anthropic in the next release, to make way for the new official Anthropic SDK (currently at https://github.com/anthropics/anthropic-sdk-ruby).
|
20
|
+
- The gem name 'anthropic' will soon refer to the official Anthropic SDK. You'll need to update your Gemfile to 'ruby-anthropic' if you want to keep using this gem.
|
21
|
+
|
22
|
+
## [0.4.0] - 2025-03-25
|
23
|
+
|
24
|
+
### Added
|
25
|
+
|
26
|
+
- Add Batches API! Thanks to [@ignacio-chiazzo](https://github.com/ignacio-chiazzo) for previous work on this.
|
27
|
+
- Thanks to [@seuros](https://github.com/seuros) for helpful README notes on Batch usage.
|
28
|
+
|
29
|
+
## [0.3.2] - 2024-10-09
|
30
|
+
|
31
|
+
### Fixed
|
32
|
+
|
33
|
+
- Fix for use with older versions of Faraday pre-v2.5.0. Thanks to [@geeosh](https://github.com/geeosh) for the PR!
|
34
|
+
|
35
|
+
## [0.3.1] - 2024-10-09
|
36
|
+
|
37
|
+
### Fixed
|
38
|
+
|
39
|
+
- Fix for Tool streaming. Thanks to [@Leteyski](https://github.com/Leteyski) for this fix!
|
40
|
+
|
41
|
+
## [0.3.0] - 2024-06-10
|
42
|
+
|
43
|
+
### Added
|
44
|
+
|
45
|
+
- Add chat streaming! Thank you to the inimitable [@swombat](https://github.com/swombat) for adding this vital functionality!
|
46
|
+
|
47
|
+
## [0.2.0] - 2024-04-25
|
48
|
+
|
49
|
+
### Added
|
50
|
+
|
51
|
+
- Add new Messages endpoint - thanks [@svs](https://github.com/svs) for the PR, [@obie](https://github.com/obie) for the first pass, and many others for requesting and contributions!
|
52
|
+
|
53
|
+
## [0.1.0] - 2023-07-18
|
54
|
+
|
55
|
+
### Changed
|
56
|
+
|
57
|
+
- Got the gem working with the API. MVP
|
58
|
+
|
59
|
+
## [0.0.0] - 2023-07-12
|
60
|
+
|
61
|
+
### Added
|
62
|
+
|
63
|
+
- Initialise repository.
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at alexrudall@users.noreply.github.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
## Contributing
|
2
|
+
|
3
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/alexrudall/ruby-anthropic. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/alexrudall/ruby-anthropic/blob/main/CODE_OF_CONDUCT.md).
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Include gem dependencies from anthropic.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "byebug", "~> 11.1.3"
|
7
|
+
gem "dotenv", "~> 2.8.1"
|
8
|
+
gem "racc", "~> 1.7.3"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.12"
|
11
|
+
gem "rubocop", "~> 1.50.2"
|
12
|
+
gem "vcr", "~> 6.1.0"
|
13
|
+
gem "webmock", "~> 3.18.1"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby-anthropic (0.4.2)
|
5
|
+
event_stream_parser (>= 0.3.0, < 2.0.0)
|
6
|
+
faraday (>= 1)
|
7
|
+
faraday-multipart (>= 1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.1)
|
13
|
+
public_suffix (>= 2.0.2, < 6.0)
|
14
|
+
ast (2.4.2)
|
15
|
+
byebug (11.1.3)
|
16
|
+
crack (0.4.5)
|
17
|
+
rexml
|
18
|
+
diff-lcs (1.5.0)
|
19
|
+
dotenv (2.8.1)
|
20
|
+
event_stream_parser (1.0.0)
|
21
|
+
faraday (2.7.10)
|
22
|
+
faraday-net_http (>= 2.0, < 3.1)
|
23
|
+
ruby2_keywords (>= 0.0.4)
|
24
|
+
faraday-multipart (1.0.4)
|
25
|
+
multipart-post (~> 2)
|
26
|
+
faraday-net_http (3.0.2)
|
27
|
+
hashdiff (1.0.1)
|
28
|
+
json (2.6.3)
|
29
|
+
multipart-post (2.3.0)
|
30
|
+
parallel (1.22.1)
|
31
|
+
parser (3.2.2.0)
|
32
|
+
ast (~> 2.4.1)
|
33
|
+
public_suffix (5.0.1)
|
34
|
+
racc (1.7.3)
|
35
|
+
rainbow (3.1.1)
|
36
|
+
rake (13.0.6)
|
37
|
+
regexp_parser (2.8.0)
|
38
|
+
rexml (3.2.5)
|
39
|
+
rspec (3.12.0)
|
40
|
+
rspec-core (~> 3.12.0)
|
41
|
+
rspec-expectations (~> 3.12.0)
|
42
|
+
rspec-mocks (~> 3.12.0)
|
43
|
+
rspec-core (3.12.0)
|
44
|
+
rspec-support (~> 3.12.0)
|
45
|
+
rspec-expectations (3.12.2)
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
47
|
+
rspec-support (~> 3.12.0)
|
48
|
+
rspec-mocks (3.12.3)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.12.0)
|
51
|
+
rspec-support (3.12.0)
|
52
|
+
rubocop (1.50.2)
|
53
|
+
json (~> 2.3)
|
54
|
+
parallel (~> 1.10)
|
55
|
+
parser (>= 3.2.0.0)
|
56
|
+
rainbow (>= 2.2.2, < 4.0)
|
57
|
+
regexp_parser (>= 1.8, < 3.0)
|
58
|
+
rexml (>= 3.2.5, < 4.0)
|
59
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
62
|
+
rubocop-ast (1.28.0)
|
63
|
+
parser (>= 3.2.1.0)
|
64
|
+
ruby-progressbar (1.13.0)
|
65
|
+
ruby2_keywords (0.0.5)
|
66
|
+
unicode-display_width (2.4.2)
|
67
|
+
vcr (6.1.0)
|
68
|
+
webmock (3.18.1)
|
69
|
+
addressable (>= 2.8.0)
|
70
|
+
crack (>= 0.3.2)
|
71
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
ruby
|
75
|
+
|
76
|
+
DEPENDENCIES
|
77
|
+
byebug (~> 11.1.3)
|
78
|
+
dotenv (~> 2.8.1)
|
79
|
+
racc (~> 1.7.3)
|
80
|
+
rake (~> 13.0)
|
81
|
+
rspec (~> 3.12)
|
82
|
+
rubocop (~> 1.50.2)
|
83
|
+
ruby-anthropic!
|
84
|
+
vcr (~> 6.1.0)
|
85
|
+
webmock (~> 3.18.1)
|
86
|
+
|
87
|
+
BUNDLED WITH
|
88
|
+
2.4.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Alex
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|