ework-web 0.10.125 → 0.10.127
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/package.json +1 -1
- package/src/translate.ts +9 -1
package/package.json
CHANGED
package/src/translate.ts
CHANGED
|
@@ -12,7 +12,11 @@ export class TranslateError extends Error {
|
|
|
12
12
|
const SYSTEM_PROMPT =
|
|
13
13
|
"Translate the following English text to Simplified Chinese. Preserve ALL markdown formatting (bullet lists with - or *, **bold**, `code`, # headings). Output ONLY the translation, nothing else.";
|
|
14
14
|
const MAX_CHARS = 16_000;
|
|
15
|
-
|
|
15
|
+
// Per-request ceiling (covers connect + queue + prefill + generation for one
|
|
16
|
+
// chunk). The shared self-hosted server also serves agent traffic; time-to-
|
|
17
|
+
// first-token can reach minutes when long-context prefills are queued ahead,
|
|
18
|
+
// so this must tolerate far more than an interactive RTT.
|
|
19
|
+
const TIMEOUT_MS = 180_000;
|
|
16
20
|
|
|
17
21
|
// OpenAI-compatible chat-completion shapes (vLLM serves /v1/chat/completions).
|
|
18
22
|
interface ChatChoice {
|
|
@@ -41,6 +45,9 @@ export async function translateText(cfg: Config, text: string): Promise<string>
|
|
|
41
45
|
body: JSON.stringify({
|
|
42
46
|
model: cfg.translateModel,
|
|
43
47
|
stream: false,
|
|
48
|
+
// Reasoning-off: translation needs none, and reasoning tokens delay
|
|
49
|
+
// time-to-first-token past interactive patience on the shared server.
|
|
50
|
+
chat_template_kwargs: { enable_thinking: false },
|
|
44
51
|
messages: [
|
|
45
52
|
{ role: "system", content: SYSTEM_PROMPT },
|
|
46
53
|
{ role: "user", content: body },
|
|
@@ -117,6 +124,7 @@ async function* streamOneChunk(cfg: Config, chunk: string): AsyncGenerator<strin
|
|
|
117
124
|
body: JSON.stringify({
|
|
118
125
|
model: cfg.translateModel,
|
|
119
126
|
stream: true,
|
|
127
|
+
chat_template_kwargs: { enable_thinking: false },
|
|
120
128
|
messages: [
|
|
121
129
|
{ role: "system", content: SYSTEM_PROMPT },
|
|
122
130
|
{ role: "user", content: chunk },
|