transl8-srt 1.0.2 → 1.1.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.
package/README.md CHANGED
@@ -59,9 +59,11 @@ console.log(result.stats);
59
59
  // totalCues: 2,
60
60
  // totalSentences: 1,
61
61
  // totalBatches: 1,
62
+ // failedBatches: [],
62
63
  // inputTokens: 312,
63
64
  // outputTokens: 48,
64
65
  // estimatedCostUsd: 0.0000528,
66
+ // costTracked: true,
65
67
  // durationMs: 843
66
68
  // }
67
69
  ```
@@ -166,11 +168,23 @@ interface TranslateOptions {
166
168
  batchSize?: number; // Sentences per API call. Default: 25
167
169
  contextOverlap?: number; // Overlap sentences from prior batch. Default: 4
168
170
  concurrency?: number; // Parallel API requests. Default: 8
171
+ maxBatchTokens?: number; // Soft token budget/batch (~4 chars/token heuristic). Default: 4000
172
+ jsonMode?: boolean; // Request response_format: json_object. Default: true
169
173
  model?: "gpt-4o" | "gpt-4o-mini"; // Auto-selected based on targetLang if omitted
170
174
  primer?: boolean; // AI-inferred style profile. Default: false
171
175
  }
172
176
  ```
173
177
 
178
+ A batch closes as soon as either `batchSize` sentences or `maxBatchTokens`
179
+ (estimated) is reached — whichever comes first. This keeps a batch of a few
180
+ long, run-on sentences from producing an oversized request even though it's
181
+ under the sentence-count cap.
182
+
183
+ If a batch fails after retries, `translate()` does **not** throw — that
184
+ batch's cues keep their original (untranslated) text, and the batch's index
185
+ is reported in `result.stats.failedBatches` so you can detect and re-run
186
+ just the failed portion if needed.
187
+
174
188
  ### Auto model selection
175
189
 
176
190
  | Target language | Auto model |