anthropic 0.4.0 → 0.4.1
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 +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +19 -4
- data/lib/anthropic/client.rb +2 -0
- data/lib/anthropic/http.rb +1 -1
- data/lib/anthropic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9def8893a5bf773385f2acf8cab126f65fcaf8c14c0aa30809ce20150221da8
|
4
|
+
data.tar.gz: eb2fd9b075ff306205857c4ecd926c9a1d0e82d20a5c91c1d03711c7947090f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a4c4015f3b2416adbe94b7a2170eb61dcecc7e87f71e6f26f7006006bd15801c9a28197af6892cf0f0393f8e6c9901a625419ebf9d5bee425c2de4ef514bc9d
|
7
|
+
data.tar.gz: 2e2ab2e3e71affe935a42e54e8e38eea23ec31a37495d8c1e9004aff96fd24163e802efe64de7b32e3e4304743525788a0a0337c9a90d0f79e478471c330f2c4
|
data/CHANGELOG.md
CHANGED
@@ -5,11 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.4.1] - 2025-04-10
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- 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).
|
13
|
+
- 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.
|
14
|
+
|
8
15
|
## [0.4.0] - 2025-03-25
|
9
16
|
|
10
17
|
### Added
|
11
18
|
|
12
19
|
- Add Batches API! Thanks to [@ignacio-chiazzo](https://github.com/ignacio-chiazzo) for previous work on this.
|
20
|
+
- Thanks to [@seuros](https://github.com/seuros) for helpful README notes on Batch usage.
|
13
21
|
|
14
22
|
## [0.3.2] - 2024-10-09
|
15
23
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
[](https://github.com/alexrudall/anthropic/blob/main/LICENSE.txt)
|
5
5
|
[](https://circleci.com/gh/alexrudall/anthropic)
|
6
6
|
|
7
|
+
> [!IMPORTANT]
|
8
|
+
> This gem has been renamed from `anthropic` to `ruby-anthropic`, to make way for the new [official Anthropic Ruby SDK](https://github.com/anthropics/anthropic-sdk-ruby) 🎉
|
9
|
+
> If you wish to keep using this gem, you just need to update your Gemfile from `anthropic` to `ruby-anthropic` and version `0.4.2` or greater. No other changes are needed and it will continue to work as normal.
|
10
|
+
|
7
11
|
Use the [Anthropic API](https://docs.anthropic.com/claude/reference/getting-started-with-the-api) with Ruby! 🤖🌌
|
8
12
|
|
9
13
|
You can get access to the API [here](https://docs.anthropic.com/claude/docs/getting-access-to-claude).
|
@@ -149,7 +153,9 @@ response = client.messages(
|
|
149
153
|
```
|
150
154
|
|
151
155
|
### Batches
|
152
|
-
The Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing
|
156
|
+
The Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing a soon as possible.
|
157
|
+
|
158
|
+
Batches can contain up to 100,000 requests or 256 MB in total size, whichever limit is reached first.
|
153
159
|
|
154
160
|
Create a batch of message requests:
|
155
161
|
```ruby
|
@@ -197,6 +203,15 @@ List all batches:
|
|
197
203
|
client.messages.batches.list
|
198
204
|
```
|
199
205
|
|
206
|
+
#### Notes (as of 31 March 2025)
|
207
|
+
|
208
|
+
- If individual batch items have errors, you will not be billed for those specific items.
|
209
|
+
- Batches will be listed in the account indefinitely.
|
210
|
+
- Results are fetchable only within 29 days after batch creation.
|
211
|
+
- When you cancel a batch, any unprocessed items will not be billed.
|
212
|
+
- Batches in other workspaces are not accessible with API keys from a different workspace.
|
213
|
+
- If a batch item takes more than 24 hours to process, it will expire and not be billed.
|
214
|
+
|
200
215
|
Once processing ends, you can fetch the results:
|
201
216
|
```ruby
|
202
217
|
results = client.messages.batches.results(id: batch_id)
|
@@ -204,7 +219,7 @@ results = client.messages.batches.results(id: batch_id)
|
|
204
219
|
|
205
220
|
Results are returned as a .jsonl file, with each line containing the result of a single request. Results may be in any order - use the custom_id field to match results to requests.
|
206
221
|
|
207
|
-
|
222
|
+
### Vision
|
208
223
|
|
209
224
|
Claude 3 family of models comes with vision capabilities that allow Claude to understand and analyze images.
|
210
225
|
|
@@ -250,14 +265,14 @@ response = client.messages(
|
|
250
265
|
```
|
251
266
|
|
252
267
|
|
253
|
-
|
268
|
+
### Additional parameters
|
254
269
|
|
255
270
|
You can add other parameters to the parameters hash, like `temperature` and even `top_k` or `top_p`. They will just be passed to the Anthropic server. You
|
256
271
|
can read more about the supported parameters [here](https://docs.anthropic.com/claude/reference/messages_post).
|
257
272
|
|
258
273
|
There are two special parameters, though, to do with... streaming. Keep reading to find out more.
|
259
274
|
|
260
|
-
|
275
|
+
### JSON
|
261
276
|
|
262
277
|
If you want your output to be json, it is recommended to provide an additional message like this:
|
263
278
|
|
data/lib/anthropic/client.rb
CHANGED
@@ -26,6 +26,8 @@ module Anthropic
|
|
26
26
|
)
|
27
27
|
end
|
28
28
|
@faraday_middleware = faraday_middleware
|
29
|
+
log "[WARNING] Gem `anthropic` was renamed to `ruby-anthropic`.
|
30
|
+
Please update your Gemfile to use `ruby-anthropic` version 0.4.2 or later."
|
29
31
|
end
|
30
32
|
|
31
33
|
# @deprecated (but still works while Anthropic API responds to it)
|
data/lib/anthropic/http.rb
CHANGED
@@ -148,7 +148,7 @@ module Anthropic
|
|
148
148
|
def log(error)
|
149
149
|
logger = Logger.new($stdout)
|
150
150
|
logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
151
|
-
"\033[31mAnthropic
|
151
|
+
"\033[31mAnthropic Error (spotted in anthropic #{VERSION}): #{msg}\n\033[0m"
|
152
152
|
end
|
153
153
|
logger.error(error)
|
154
154
|
end
|
data/lib/anthropic/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anthropic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: event_stream_parser
|