deepl-rb 3.4.1 → 3.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c41f4e48cdf057f165925df1ba47e6fa2748d49816a16e137e4ed8acaed7000
4
- data.tar.gz: b169350c8f173e15bc502d7eaa26c6b9b4b255961224a6508ac41eaa0d7466c3
3
+ metadata.gz: a72aff32a39743d19e811efa5a3e9d5687b90c0f3f06e1545b3746143a7478b7
4
+ data.tar.gz: 02b0f280c59a81c24771a2c2d4248d9fb4d32bcb3a635dc9e8a0a8cf6ce8db71
5
5
  SHA512:
6
- metadata.gz: 0d260ad680a40b28865127fd0eaccd469c7dc5fed1203424c3737077b6d5b6a7dc6116b3d458633f8c3d4835159b5deb1e49bafa43409a1255abd3f11ccbbba6
7
- data.tar.gz: 1d684b486e4286f02d6bbc194bcf983ee7e5555d263d52cc5b41d68abba2fbafe79bae96f014b1db841b9fb893b173dc66f12365b7734bbd3bfb9a891ff97b41
6
+ metadata.gz: c292502b6e5c35a73f79ddacbe7f44ea2c1ba51d12eb137a795e44f6f10c56f397277eea272faf193a4fb14c6f639fe597c0c066feca1cce03ad5584cf2d3224
7
+ data.tar.gz: 31f9cfdd8e9f762f30ff37e5de3aa3466527330e14aa6378d0c1bc2454c9f78249a74546998bfbf90ba56ef46e77fe4c09885cc82d489db615ab7a2ff89f3f7e
data/CHANGELOG.md CHANGED
@@ -4,9 +4,18 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [3.4.1] - 2025-12-19
7
+ ## [3.5.1] - 2025-12-19
8
8
  ### Fixed
9
- - Fixed broken 3.4.0 release
9
+ - Fixed broken 3.5.0 release
10
+
11
+ ## [3.5.0] - 2025-12-03
12
+ ### Added
13
+ - Added `custom_instructions` parameter to `translate()` to customize translation
14
+ behavior with up to 10 instructions (max 300 characters each). Only supported for
15
+ target languages: `de`, `en`, `es`, `fr`, `it`, `ja`, `ko`, `zh` and their variants.
16
+ Note: using the `custom_instructions` parameter will use the `quality_optimized`
17
+ model type as the default. Requests combining `custom_instructions` and the
18
+ `latency_optimized` model type will be rejected.
10
19
 
11
20
  ## [3.4.0] - 2025-11-17
12
21
  ### Added
@@ -75,7 +84,8 @@ The change in major version is only due to the change in maintainership, there i
75
84
  ### Fixed
76
85
  - Make RequestEntityTooLarge error message more clear
77
86
 
78
- [3.4.1]: https://github.com/DeepLcom/deepl-rb/compare/v3.4.0...v3.4.1
87
+ [3.5.1]: https://github.com/DeepLcom/deepl-rb/compare/v3.5.0...v3.5.1
88
+ [3.5.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.4.0...v3.5.0
79
89
  [3.4.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.3.0...v3.4.0
80
90
  [3.3.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.2.0...v3.3.0
81
91
  [3.2.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.1.0...v3.2.0
data/README.md CHANGED
@@ -153,6 +153,19 @@ This would use next-gen translation models for the translation. The available va
153
153
  - `'latency_optimized'`: use a translation model that minimizes response time, at the cost
154
154
  of translation quality.
155
155
 
156
+ To translate with custom instructions, supply the `custom_instructions` parameter:
157
+
158
+ ```rb
159
+ translation = DeepL.translate 'Hello, world!', 'EN', 'DE',
160
+ custom_instructions: ['Use informal language', 'Be concise']
161
+
162
+ puts translation.text
163
+ ```
164
+
165
+ Up to 10 custom instructions can be specified, each with a maximum of 300 characters.
166
+ The target language must be `de`, `en`, `es`, `fr`, `it`, `ja`, `ko`, `zh` or any variants.
167
+ Note that using `custom_instructions` will automatically use `quality_optimized` models,
168
+ and cannot be combined with `model_type: 'latency_optimized'`.
156
169
 
157
170
  The following parameters will be automatically converted:
158
171
 
@@ -169,6 +182,7 @@ The following parameters will be automatically converted:
169
182
  | `style_id` | No conversion applied
170
183
  | `style_rule` | No conversion applied (can be a string ID or a StyleRule object)
171
184
  | `context` | No conversion applied
185
+ | `custom_instructions` | No conversion applied
172
186
  | `extra_body_parameters` | Hash of extra parameters to pass in the body of the HTTP request. Can be used to access beta features, or to override built-in parameters for testing purposes. Extra parameters can override keys explicitly set by the client.
173
187
 
174
188
  ### Rephrase Text
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.4.1
1
+ 3.5.1
data/deepl-rb.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: deepl-rb 3.4.1 ruby lib
5
+ # stub: deepl-rb 3.5.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "deepl-rb".freeze
9
- s.version = "3.4.1"
9
+ s.version = "3.5.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.metadata = { "bug_tracker_uri" => "https://github.com/DeepLcom/deepl-rb/issues", "changelog_uri" => "https://github.com/DeepLcom/deepl-rb/blob/main/CHANGELOG.md", "documentation_uri" => "https://github.com/DeepLcom/deepl-rb/blob/main/README.md", "homepage_uri" => "https://github.com/DeepLcom/deepl-rb" } if s.respond_to? :metadata=
@@ -23,11 +23,12 @@ module DeepL
23
23
  outline_detection: STRING_TO_BOOLEAN_CONVERSION,
24
24
  splitting_tags: STRING_TO_ARRAY_CONVERSION,
25
25
  non_splitting_tags: STRING_TO_ARRAY_CONVERSION,
26
- ignore_tags: STRING_TO_ARRAY_CONVERSION
26
+ ignore_tags: STRING_TO_ARRAY_CONVERSION,
27
+ custom_instructions: STRING_TO_ARRAY_CONVERSION
27
28
  }.freeze
28
29
 
29
30
  attr_reader :text, :source_lang, :target_lang, :ignore_tags, :splitting_tags,
30
- :non_splitting_tags, :model_type
31
+ :non_splitting_tags, :model_type, :custom_instructions
31
32
 
32
33
  def initialize(api, text, source_lang, target_lang, options = {})
33
34
  super(api, options)
data/lib/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # frozen_string_literal: true
5
5
 
6
6
  module DeepL
7
- VERSION = '3.4.1'
7
+ VERSION = '3.5.1'
8
8
  end
@@ -10412,4 +10412,47 @@ http_interactions:
10412
10412
  string: !binary |-
10413
10413
  eyJ0cmFuc2xhdGlvbnMiOlt7ImRldGVjdGVkX3NvdXJjZV9sYW5ndWFnZSI6IkVOIiwidGV4dCI6IlRleHRlIG1vZMOobGUifV19
10414
10414
  recorded_at: Tue, 28 Oct 2025 12:50:23 GMT
10415
+ - request:
10416
+ method: post
10417
+ uri: https://api.deepl.com/v2/translate
10418
+ body:
10419
+ encoding: UTF-8
10420
+ string: '{"text":["Hello world"],"source_lang":"EN","target_lang":"DE","custom_instructions":["Use
10421
+ formal language","Be concise"]}'
10422
+ headers:
10423
+ Authorization:
10424
+ - DeepL-Auth-Key VALID_TOKEN
10425
+ User-Agent:
10426
+ - deepl-ruby/3.5.0 (darwin24) ruby/3.2.2
10427
+ Content-Type:
10428
+ - application/json
10429
+ Accept-Encoding:
10430
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
10431
+ Accept:
10432
+ - "*/*"
10433
+ response:
10434
+ status:
10435
+ code: 200
10436
+ message: OK
10437
+ headers:
10438
+ Content-Type:
10439
+ - application/json
10440
+ Date:
10441
+ - Wed, 03 Dec 2025 06:07:36 GMT
10442
+ X-Trace-Id:
10443
+ - b50df453ea8d451bbd67df63f68e66da
10444
+ Access-Control-Expose-Headers:
10445
+ - Server-Timing, X-Trace-ID
10446
+ Server-Timing:
10447
+ - l7_lb_tls;dur=117, l7_lb_idle;dur=4, l7_lb_receive;dur=0, l7_lb_total;dur=340
10448
+ Strict-Transport-Security:
10449
+ - max-age=63072000; includeSubDomains; preload
10450
+ Transfer-Encoding:
10451
+ - chunked
10452
+ Vary:
10453
+ - Accept-Encoding
10454
+ body:
10455
+ encoding: ASCII-8BIT
10456
+ string: '{"translations":[{"text":"Sehr geehrte Damen und Herren","detected_source_language":"EN"}]}'
10457
+ recorded_at: Wed, 03 Dec 2025 06:07:36 GMT
10415
10458
  recorded_with: VCR 6.3.1
@@ -225,6 +225,30 @@ describe DeepL::Requests::Translate do
225
225
  expect(request.options[:model_type]).to eq('latency_optimized')
226
226
  end
227
227
  end
228
+
229
+ context 'when using `custom_instructions` options' do
230
+ it 'works with a nil value' do
231
+ request = described_class.new(api, nil, nil, nil, custom_instructions: nil)
232
+ expect(request.options[:custom_instructions]).to be_nil
233
+ end
234
+
235
+ it 'works with an array of strings' do
236
+ instructions = ['Use informal language', 'Be concise']
237
+ request = described_class.new(api, nil, nil, nil, custom_instructions: instructions)
238
+ expect(request.options[:custom_instructions]).to eq(instructions)
239
+ end
240
+
241
+ it 'works with a single string' do
242
+ request = described_class.new(api, nil, nil, nil, custom_instructions: ['Be concise'])
243
+ expect(request.options[:custom_instructions]).to eq(['Be concise'])
244
+ end
245
+
246
+ it 'works with a single string and converts it to an array' do
247
+ instructions = 'Use informal language,Be concise'
248
+ request = described_class.new(api, nil, nil, nil, custom_instructions: instructions)
249
+ expect(request.options[:custom_instructions]).to eq(['Use informal language', 'Be concise'])
250
+ end
251
+ end
228
252
  end
229
253
 
230
254
  describe '#request' do
@@ -378,6 +402,19 @@ describe DeepL::Requests::Translate do
378
402
  end
379
403
  end
380
404
 
405
+ context 'when performing a request with custom_instructions' do
406
+ let(:text) { 'Hello world' }
407
+ let(:target_lang) { 'DE' }
408
+
409
+ it 'includes custom_instructions in the payload' do
410
+ options = { custom_instructions: ['Use formal language', 'Be concise'] }
411
+ translate = described_class.new(api, text, source_lang, target_lang, options)
412
+
413
+ # Verify the options are properly stored
414
+ expect(translate.options[:custom_instructions]).to eq(['Use formal language', 'Be concise'])
415
+ end
416
+ end
417
+
381
418
  context 'when performing a bad request' do
382
419
  context 'when using an invalid token' do
383
420
  let(:api) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deepl-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DeepL SE