vidspotai-shared 1.0.104 → 1.0.105
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translation.service.d.ts","sourceRoot":"","sources":["../../../src/services/translation/translation.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAqGvD;;;;GAIG;AACH,iBAAe,SAAS,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,OAAO,GAAE,IAAI,GAAG,IAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAsCjB;
|
|
1
|
+
{"version":3,"file":"translation.service.d.ts","sourceRoot":"","sources":["../../../src/services/translation/translation.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAqGvD;;;;GAIG;AACH,iBAAe,SAAS,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,EACpB,EAAE,GAAE,cAAkC,EACtC,OAAO,GAAE,IAAI,GAAG,IAAW,GAC1B,OAAO,CAAC,MAAM,CAAC,CAsCjB;AAiDD;;;;;;;;;;;;;;GAcG;AACH,iBAAe,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA8ChE;AAOD,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC;AAGF,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,kBAAY,CAAC;AAC/C,0DAA0D;AAC1D,eAAO,MAAM,UAAU,uBAAiB,CAAC"}
|
|
@@ -199,15 +199,29 @@ async function callLlmDetect(text) {
|
|
|
199
199
|
"code of the language the user's text is written in — two lowercase " +
|
|
200
200
|
'letters, nothing else (e.g. "es", "ja", "ar"). Use "zh-cn" or "zh-tw" ' +
|
|
201
201
|
"for Chinese. No punctuation, no explanation.";
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
202
|
+
// Bounded the same way as callLlmTranslate (see comment above it): this is
|
|
203
|
+
// called synchronously from POST /v1/video/generate before the BullMQ
|
|
204
|
+
// enqueue, so an unbounded generateText here stalls the HTTP request all
|
|
205
|
+
// the way to the Cloud Run 300s ceiling instead of failing over to the
|
|
206
|
+
// "default to en" path below.
|
|
207
|
+
let timer;
|
|
208
|
+
const { text: out } = await Promise.race([
|
|
209
|
+
service.generateText({
|
|
210
|
+
// Only the opening slice matters for identification, and capping it
|
|
211
|
+
// keeps this cheap when a long-form brief triggers the fallback.
|
|
212
|
+
input: [
|
|
213
|
+
{ role: "system", content: system },
|
|
214
|
+
{ role: "user", content: text.slice(0, 1000) },
|
|
215
|
+
],
|
|
216
|
+
modelKey: FALLBACK_MODEL,
|
|
217
|
+
options: { temperature: 0 },
|
|
218
|
+
}),
|
|
219
|
+
new Promise((_, reject) => {
|
|
220
|
+
timer = setTimeout(() => reject(new Error(`LLM detect timed out after ${FALLBACK_TIMEOUT_MS}ms`)), FALLBACK_TIMEOUT_MS);
|
|
221
|
+
}),
|
|
222
|
+
]).finally(() => {
|
|
223
|
+
if (timer)
|
|
224
|
+
clearTimeout(timer);
|
|
211
225
|
});
|
|
212
226
|
const code = (out ?? "").trim().toLowerCase().replace(/[^a-z-]/g, "");
|
|
213
227
|
if (!/^[a-z]{2}(-[a-z]{2})?$/.test(code)) {
|