lara-sdk 1.9.2 → 1.10.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 +4 -4
- data/lib/lara/models/text.rb +67 -3
- data/lib/lara/translator.rb +4 -1
- data/lib/lara/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: 33000e4a2972ae2f98c8e9b2e307122e4d729d1e50e5d78325fde5d5b7d470b4
|
|
4
|
+
data.tar.gz: 11a9586abaf2b895fe0d7f50f04470c462b80f83c44ffb33a9a4c869c30bb4bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bab5b019aaab9736023be72456df455558afcc17dce5060792c6b4d8fe73a34c81065a86320614437a234792b6ca204ddddd3884049e0927e51d16d894eb3441
|
|
7
|
+
data.tar.gz: 0a5bd84f86a55cce9ab60930178411857cc84df2534d6b91deb5300ab0e9ff12bdc126a7e374458d83a64c7cd105dda4ba6852b4eac313b40852e528941d7158
|
data/lib/lara/models/text.rb
CHANGED
|
@@ -167,11 +167,73 @@ module Lara
|
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
+
class IntelligenceError < Base
|
|
171
|
+
attr_reader :status_code, :message
|
|
172
|
+
|
|
173
|
+
def initialize(status_code:, message:)
|
|
174
|
+
super()
|
|
175
|
+
@status_code = status_code
|
|
176
|
+
@message = message
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def self.from_hash(hash)
|
|
180
|
+
return nil if hash.nil?
|
|
181
|
+
|
|
182
|
+
new(status_code: hash["statusCode"] || hash["status_code"], message: hash["message"])
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
class IntelligenceFailure < Base
|
|
187
|
+
attr_reader :applied, :error
|
|
188
|
+
|
|
189
|
+
def initialize(applied:, error:)
|
|
190
|
+
super()
|
|
191
|
+
@applied = applied
|
|
192
|
+
@error = IntelligenceError.from_hash(error)
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Applied is false or "partial" for reference retrieval failures.
|
|
197
|
+
class ReferenceRetrievalFailure < IntelligenceFailure
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
class ReasoningWarning < Base
|
|
201
|
+
attr_reader :code, :message
|
|
202
|
+
|
|
203
|
+
def initialize(code:, message:)
|
|
204
|
+
super()
|
|
205
|
+
@code = code
|
|
206
|
+
@message = message
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
class ReasoningFeedback < Base
|
|
211
|
+
attr_reader :applied, :error, :warnings
|
|
212
|
+
|
|
213
|
+
def initialize(applied:, error: nil, warnings: [])
|
|
214
|
+
super()
|
|
215
|
+
@applied = applied
|
|
216
|
+
@error = IntelligenceError.from_hash(error)
|
|
217
|
+
@warnings = warnings.map { |warning| ReasoningWarning.new(**warning.transform_keys(&:to_sym)) }
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
class TextWarnings < Base
|
|
222
|
+
attr_reader :reasoning, :references, :prosa
|
|
223
|
+
|
|
224
|
+
def initialize(reasoning: nil, references: nil, prosa: nil)
|
|
225
|
+
super()
|
|
226
|
+
@reasoning = ReasoningFeedback.new(**reasoning.transform_keys(&:to_sym)) if reasoning
|
|
227
|
+
@references = ReferenceRetrievalFailure.new(**references.transform_keys(&:to_sym)) if references
|
|
228
|
+
@prosa = IntelligenceFailure.new(**prosa.transform_keys(&:to_sym)) if prosa
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
170
232
|
class TextResult < Base
|
|
171
233
|
attr_reader :content_type, :source_language, :translation,
|
|
172
234
|
:adapted_to, :glossaries,
|
|
173
235
|
:adapted_to_matches, :glossaries_matches,
|
|
174
|
-
:profanities, :styleguide_results
|
|
236
|
+
:profanities, :styleguide_results, :warnings
|
|
175
237
|
|
|
176
238
|
def self.from_hash(hash)
|
|
177
239
|
return nil unless hash.is_a?(Hash)
|
|
@@ -198,13 +260,14 @@ module Lara
|
|
|
198
260
|
adapted_to_matches: adapted_to_matches,
|
|
199
261
|
glossaries_matches: glossaries_matches,
|
|
200
262
|
profanities: profanities,
|
|
201
|
-
styleguide_results: styleguide_results
|
|
263
|
+
styleguide_results: styleguide_results,
|
|
264
|
+
warnings: hash["warnings"] && TextWarnings.new(**hash["warnings"].transform_keys(&:to_sym))
|
|
202
265
|
)
|
|
203
266
|
end
|
|
204
267
|
|
|
205
268
|
def initialize(content_type:, source_language:, translation:, adapted_to: nil, glossaries: nil,
|
|
206
269
|
adapted_to_matches: nil, glossaries_matches: nil, profanities: nil,
|
|
207
|
-
styleguide_results: nil)
|
|
270
|
+
styleguide_results: nil, warnings: nil)
|
|
208
271
|
super()
|
|
209
272
|
@content_type = content_type
|
|
210
273
|
@source_language = source_language
|
|
@@ -215,6 +278,7 @@ module Lara
|
|
|
215
278
|
@glossaries_matches = glossaries_matches
|
|
216
279
|
@profanities = profanities
|
|
217
280
|
@styleguide_results = styleguide_results
|
|
281
|
+
@warnings = warnings
|
|
218
282
|
end
|
|
219
283
|
|
|
220
284
|
class << self
|
data/lib/lara/translator.rb
CHANGED
|
@@ -56,6 +56,8 @@ module Lara
|
|
|
56
56
|
# @param verbose [Boolean]
|
|
57
57
|
# @param style [String,nil]
|
|
58
58
|
# @param reasoning [Boolean] When true with a block, yields partial results during reasoning
|
|
59
|
+
# @param image_context [Hash,Array<Hash>,nil] One HTTPS or base64 PNG/JPEG/WebP image; requires reasoning when non-empty.
|
|
60
|
+
# Image validation is performed by the API. An empty array preserves text-only translation.
|
|
59
61
|
# @param headers [Hash,nil]
|
|
60
62
|
# @param metadata [String, Hash, nil]
|
|
61
63
|
# @param profanities_detect [String,nil] One of "target", "source_target"
|
|
@@ -65,7 +67,7 @@ module Lara
|
|
|
65
67
|
def translate(text, target:, source: nil, source_hint: nil, adapt_to: nil, glossaries: nil,
|
|
66
68
|
instructions: nil, content_type: nil, multiline: true, timeout_ms: nil,
|
|
67
69
|
priority: nil, use_cache: nil, cache_ttl_s: nil, no_trace: false, verbose: false,
|
|
68
|
-
style: nil, reasoning: false, headers: nil, metadata: nil,
|
|
70
|
+
style: nil, reasoning: false, image_context: nil, headers: nil, metadata: nil,
|
|
69
71
|
profanities_detect: nil, profanities_handling: nil,
|
|
70
72
|
styleguide_id: nil, styleguide_reasoning: nil,
|
|
71
73
|
styleguide_explanation_language: nil, &callback)
|
|
@@ -94,6 +96,7 @@ module Lara
|
|
|
94
96
|
verbose: verbose,
|
|
95
97
|
style: style,
|
|
96
98
|
reasoning: reasoning,
|
|
99
|
+
image_context: image_context,
|
|
97
100
|
metadata: metadata,
|
|
98
101
|
profanities_detect: profanities_detect,
|
|
99
102
|
profanities_handling: profanities_handling,
|
data/lib/lara/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lara-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Translated
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|