lara-sdk 1.2.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20907c5322ca25cec94d4475f543ba03a04f611c8707711ca5b188b1aac5d708
4
- data.tar.gz: 41f47a2c9a56145711d5275a9f8db3b1dc9a66e3b514d4d4106cbf2fa69bcb8e
3
+ metadata.gz: 3a959c719f2393f4626f029c7116d426f1402889baeaea48a16800fbb58cd229
4
+ data.tar.gz: 54b9f604df73458c8abebb16ecce4389dcf4486f255d53187e3ad8dd7d2145c4
5
5
  SHA512:
6
- metadata.gz: 323a5b9dbe032b6cc66ca30f42cf599ebd451f29b87c9a7fa7ed0f98769b91a952c57ece507d4bf9a9a120159364c6c224059a4b7a4a09b76ec65c3a0e50f078
7
- data.tar.gz: 6123b7826259215d940b6e06e75b912756f9351cf750837e793059488472dac3ff3fc47906a4e6922b966873ea9803e240e588d9e9cf80f8c67509e3798136a0
6
+ metadata.gz: 0d29539cdb0b1fe5add2b2f3200b812666d1edd1c0ebac1d77604f9c696f1f791cac76a791a0fedf7d75d6c263086090b57116705c477f1d9455ae27bb2e4c67
7
+ data.tar.gz: 29de437c146d524cca9b29a198ebbdb3426e8bf258a073d72e9740efedcd84edb83d01156870f3a461b1d62fcb144cb52b27c178bb51a8d7b7b521593d60ecff
@@ -52,9 +52,9 @@ module Lara
52
52
  end
53
53
 
54
54
  class ProfanityDetectResult < Base
55
- attr_reader :masked_text, :profanities
55
+ attr_reader :masked_text, :profanities, :error
56
56
 
57
- def initialize(masked_text:, profanities: [])
57
+ def initialize(masked_text:, profanities: [], error: nil)
58
58
  super()
59
59
  @masked_text = masked_text
60
60
  @profanities = profanities.map do |p|
@@ -65,6 +65,22 @@ module Lara
65
65
  score: p["score"] || p[:score]
66
66
  )
67
67
  end
68
+ @error = error
69
+ end
70
+ end
71
+
72
+ # Wraps profanity detection results for both target and (optionally) source text.
73
+ # Returned in TextResult#profanities when profanities_detect is set.
74
+ class ProfanitiesResult < Base
75
+ # @return [ProfanityDetectResult, Array<ProfanityDetectResult, nil>, nil]
76
+ attr_reader :target
77
+ # @return [ProfanityDetectResult, Array<ProfanityDetectResult, nil>, nil]
78
+ attr_reader :source
79
+
80
+ def initialize(target: nil, source: nil)
81
+ super()
82
+ @target = target
83
+ @source = source
68
84
  end
69
85
  end
70
86
 
@@ -215,11 +231,23 @@ module Lara
215
231
 
216
232
  def convert_profanities(value)
217
233
  return nil if value.nil?
234
+ return nil unless value.is_a?(Hash)
235
+ return nil unless value.key?("target") || value.key?("source")
236
+
237
+ ProfanitiesResult.new(
238
+ target: parse_profanity_value(value["target"]),
239
+ source: parse_profanity_value(value["source"])
240
+ )
241
+ end
242
+
243
+ def parse_profanity_value(value)
244
+ return nil if value.nil?
218
245
 
219
246
  if value.is_a?(Hash)
220
247
  ProfanityDetectResult.new(
221
248
  masked_text: value["masked_text"],
222
- profanities: value["profanities"] || []
249
+ profanities: value["profanities"] || [],
250
+ error: value["error"]
223
251
  )
224
252
  elsif value.is_a?(Array)
225
253
  value.map do |v|
@@ -227,7 +255,8 @@ module Lara
227
255
 
228
256
  ProfanityDetectResult.new(
229
257
  masked_text: v["masked_text"],
230
- profanities: v["profanities"] || []
258
+ profanities: v["profanities"] || [],
259
+ error: v["error"]
231
260
  )
232
261
  end
233
262
  end
@@ -56,14 +56,15 @@ module Lara
56
56
  # @param reasoning [Boolean] When true with a block, yields partial results during reasoning
57
57
  # @param headers [Hash,nil]
58
58
  # @param metadata [String, Hash, nil]
59
- # @param profanity_filter [String,nil] One of "detect", "avoid", "hide"
59
+ # @param profanities_detect [String,nil] One of "target", "source_target"
60
+ # @param profanities_handling [String,nil] One of "detect", "avoid", "hide" (default: "hide" when profanities_detect is set)
60
61
  # @yield [Lara::Models::TextResult] Partial translation result (only when reasoning is true)
61
62
  # @return [Lara::Models::TextResult] Final translation result
62
63
  def translate(text, target:, source: nil, source_hint: nil, adapt_to: nil, glossaries: nil,
63
64
  instructions: nil, content_type: nil, multiline: true, timeout_ms: nil,
64
65
  priority: nil, use_cache: nil, cache_ttl_s: nil, no_trace: false, verbose: false,
65
66
  style: nil, reasoning: false, headers: nil, metadata: nil,
66
- profanity_filter: nil,
67
+ profanities_detect: nil, profanities_handling: nil,
67
68
  styleguide_id: nil, styleguide_reasoning: nil,
68
69
  styleguide_explanation_language: nil, &callback)
69
70
  q = normalize_text_input(text)
@@ -92,7 +93,8 @@ module Lara
92
93
  style: style,
93
94
  reasoning: reasoning,
94
95
  metadata: metadata,
95
- profanity_filter: profanity_filter,
96
+ profanities_detect: profanities_detect,
97
+ profanities_handling: profanities_handling,
96
98
  styleguide_id: styleguide_id,
97
99
  styleguide_reasoning: styleguide_reasoning,
98
100
  styleguide_explanation_language: styleguide_explanation_language
@@ -145,7 +147,8 @@ module Lara
145
147
  result = @client.post("/v2/detect/profanities", body: body)
146
148
  Lara::Models::ProfanityDetectResult.new(
147
149
  masked_text: result["masked_text"],
148
- profanities: result["profanities"] || []
150
+ profanities: result["profanities"] || [],
151
+ error: result["error"]
149
152
  )
150
153
  end
151
154
 
data/lib/lara/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lara
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.2"
5
5
  end
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.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Translated
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-04-21 00:00:00.000000000 Z
11
+ date: 2026-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday