llm_translate 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3d7bffb10cabd77729e1e806a256a16bd7a036faa0ea52b7024e3a521dada5e
4
- data.tar.gz: 50fcf8a22940afb311387913d2455dc519812abe8618be54c47541808193afd6
3
+ metadata.gz: 9ab1da1df23759b64860a8f6c5e33e022d8a73aa842ed494448cb121a55ecaf8
4
+ data.tar.gz: 1f3536587e0a55c4c09720584cb798538084953a1dd0bec004517f7a28eb46e6
5
5
  SHA512:
6
- metadata.gz: 76e635e0838f893377ed9ba05e8e4e04c36053cbb4c68b2ab09cbd8c69d8a7433400886e1f817647d9b322fc7dad1e4643cc53b6471fc7ed2b6538df015108d7
7
- data.tar.gz: 713bb859602fd5f511444f8e491bcd556beb7954f2f03cb36ff79938ff1e07e60c5419dd2c9818dc4d1f95136af8d4722b649a267e4217128598a26036b50532
6
+ metadata.gz: 95e9bd1e7166440b416dc9b1bc92fb6ca3b2a4f96ce9460973753cdae24ed7868cca9fd270c05a0316e3c33c96bbef9000f704a71e0f9564815e6b597e103d35
7
+ data.tar.gz: 262162b0d498b1673a1cebc5ca7ea1fcd97924ee5019fd7b000e7c8a089ac97d87e57ec0686d0cc84d755b5f3500218449f273be35cfc34ecc9b5057902691d5
@@ -39,7 +39,7 @@ module LlmTranslate
39
39
  end
40
40
 
41
41
  def max_tokens
42
- data.dig('ai', 'max_tokens') || 4000
42
+ data.dig('ai', 'max_tokens') || 40_000
43
43
  end
44
44
 
45
45
  def retry_attempts
@@ -85,15 +85,24 @@ module LlmTranslate
85
85
  end
86
86
 
87
87
  def input_file
88
+ return cli_options[:input] if cli_options[:input]
89
+
88
90
  data.dig('files', 'input_file')
89
91
  end
90
92
 
91
93
  def output_file
94
+ return cli_options[:output] if cli_options[:input] && cli_options[:output]
95
+
92
96
  data.dig('files', 'output_file')
93
97
  end
94
98
 
95
99
  def single_file_mode?
96
- !input_file.nil? && !output_file.nil?
100
+ input_file_path = input_file
101
+ output_file_path = output_file
102
+
103
+ # Both must be present and input must be a file (not directory) for single file mode
104
+ !input_file_path.nil? && !output_file_path.nil? &&
105
+ File.exist?(input_file_path) && File.file?(input_file_path)
97
106
  end
98
107
 
99
108
  def filename_strategy
@@ -196,9 +205,52 @@ module LlmTranslate
196
205
  'API key is required. Set LLM_TRANSLATE_API_KEY environment variable or configure in config file.'
197
206
  end
198
207
 
199
- return if Dir.exist?(File.dirname(input_directory))
208
+ # Validate input/output based on mode
209
+ if single_file_mode?
210
+ validate_single_file_mode
211
+ else
212
+ validate_directory_mode
213
+ end
214
+ end
215
+
216
+ def validate_single_file_mode
217
+ # Validate input file exists
218
+ unless input_file && File.exist?(input_file)
219
+ raise ConfigurationError, "Input file does not exist: #{input_file || 'not specified'}"
220
+ end
221
+
222
+ # Validate input is actually a file
223
+ unless File.file?(input_file)
224
+ raise ConfigurationError, "Input path is not a file: #{input_file}"
225
+ end
200
226
 
201
- raise ConfigurationError, "Input directory parent does not exist: #{File.dirname(input_directory)}"
227
+ # Validate output file path
228
+ unless output_file
229
+ raise ConfigurationError, "Output file must be specified for single file mode"
230
+ end
231
+
232
+ # Ensure output directory exists
233
+ output_dir = File.dirname(output_file)
234
+ unless Dir.exist?(output_dir)
235
+ begin
236
+ FileUtils.mkdir_p(output_dir)
237
+ rescue StandardError => e
238
+ raise ConfigurationError, "Cannot create output directory #{output_dir}: #{e.message}"
239
+ end
240
+ end
241
+ end
242
+
243
+ def validate_directory_mode
244
+ # Validate input directory
245
+ unless Dir.exist?(input_directory)
246
+ raise ConfigurationError, "Input directory does not exist: #{input_directory}"
247
+ end
248
+
249
+ # Ensure output directory parent exists
250
+ output_parent = File.dirname(output_directory)
251
+ unless Dir.exist?(output_parent)
252
+ raise ConfigurationError, "Output directory parent does not exist: #{output_parent}"
253
+ end
202
254
  end
203
255
 
204
256
  def resolve_env_var(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LlmTranslate
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LlmTranslate Team