speechflow 2.0.3 → 2.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +43 -14
  3. package/etc/speechflow.yaml +20 -48
  4. package/etc/stx.conf +2 -2
  5. package/package.json +5 -5
  6. package/speechflow-cli/dst/speechflow-node-a2a-gtcrn-wt.d.ts +1 -0
  7. package/speechflow-cli/dst/speechflow-node-a2a-gtcrn-wt.js +60 -0
  8. package/speechflow-cli/dst/speechflow-node-a2a-gtcrn-wt.js.map +1 -0
  9. package/speechflow-cli/dst/speechflow-node-a2a-gtcrn.d.ts +15 -0
  10. package/speechflow-cli/dst/speechflow-node-a2a-gtcrn.js +234 -0
  11. package/speechflow-cli/dst/speechflow-node-a2a-gtcrn.js.map +1 -0
  12. package/speechflow-cli/dst/speechflow-node-a2a-meter.js +2 -2
  13. package/speechflow-cli/dst/speechflow-node-a2a-meter.js.map +1 -1
  14. package/speechflow-cli/dst/speechflow-node-a2t-amazon.d.ts +1 -0
  15. package/speechflow-cli/dst/speechflow-node-a2t-amazon.js +19 -11
  16. package/speechflow-cli/dst/speechflow-node-a2t-amazon.js.map +1 -1
  17. package/speechflow-cli/dst/speechflow-node-a2t-assemblyai.d.ts +16 -0
  18. package/speechflow-cli/dst/speechflow-node-a2t-assemblyai.js +275 -0
  19. package/speechflow-cli/dst/speechflow-node-a2t-assemblyai.js.map +1 -0
  20. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +32 -15
  21. package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -1
  22. package/speechflow-cli/dst/speechflow-node-a2t-openai.js +7 -6
  23. package/speechflow-cli/dst/speechflow-node-a2t-openai.js.map +1 -1
  24. package/speechflow-cli/dst/speechflow-node-t2a-amazon.js +2 -4
  25. package/speechflow-cli/dst/speechflow-node-t2a-amazon.js.map +1 -1
  26. package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +3 -3
  27. package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -1
  28. package/speechflow-cli/dst/speechflow-node-t2a-google.js.map +1 -1
  29. package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js +1 -1
  30. package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js.map +1 -1
  31. package/speechflow-cli/dst/speechflow-node-t2t-amazon.js +9 -8
  32. package/speechflow-cli/dst/speechflow-node-t2t-amazon.js.map +1 -1
  33. package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +3 -3
  34. package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -1
  35. package/speechflow-cli/dst/speechflow-node-t2t-opus.js +5 -5
  36. package/speechflow-cli/dst/speechflow-node-t2t-opus.js.map +1 -1
  37. package/speechflow-cli/dst/speechflow-node-t2t-profanity.js +26 -6
  38. package/speechflow-cli/dst/speechflow-node-t2t-profanity.js.map +1 -1
  39. package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js.map +1 -1
  40. package/speechflow-cli/dst/speechflow-node-t2t-sentence.d.ts +1 -0
  41. package/speechflow-cli/dst/speechflow-node-t2t-sentence.js +72 -5
  42. package/speechflow-cli/dst/speechflow-node-t2t-sentence.js.map +1 -1
  43. package/speechflow-cli/dst/speechflow-node-t2t-spellcheck.js.map +1 -1
  44. package/speechflow-cli/dst/speechflow-node-t2t-summary.js.map +1 -1
  45. package/speechflow-cli/dst/speechflow-node-t2t-translate.js +50 -25
  46. package/speechflow-cli/dst/speechflow-node-t2t-translate.js.map +1 -1
  47. package/speechflow-cli/etc/oxlint.jsonc +9 -1
  48. package/speechflow-cli/etc/stx.conf +1 -1
  49. package/speechflow-cli/package.d/sherpa-onnx+1.12.23.patch +12 -0
  50. package/speechflow-cli/package.json +23 -19
  51. package/speechflow-cli/src/lib.d.ts +30 -4
  52. package/speechflow-cli/src/speechflow-node-a2a-gtcrn-wt.ts +68 -0
  53. package/speechflow-cli/src/speechflow-node-a2a-gtcrn.ts +219 -0
  54. package/speechflow-cli/src/speechflow-node-a2a-meter.ts +2 -2
  55. package/speechflow-cli/src/speechflow-node-a2t-amazon.ts +21 -12
  56. package/speechflow-cli/src/speechflow-node-a2t-deepgram.ts +33 -15
  57. package/speechflow-cli/src/speechflow-node-a2t-openai.ts +9 -8
  58. package/speechflow-cli/src/speechflow-node-t2a-amazon.ts +2 -4
  59. package/speechflow-cli/src/speechflow-node-t2a-elevenlabs.ts +3 -3
  60. package/speechflow-cli/src/speechflow-node-t2a-google.ts +2 -2
  61. package/speechflow-cli/src/speechflow-node-t2a-supertonic.ts +1 -1
  62. package/speechflow-cli/src/speechflow-node-t2t-amazon.ts +11 -10
  63. package/speechflow-cli/src/speechflow-node-t2t-deepl.ts +3 -3
  64. package/speechflow-cli/src/speechflow-node-t2t-opus.ts +6 -6
  65. package/speechflow-cli/src/speechflow-node-t2t-profanity.ts +30 -11
  66. package/speechflow-cli/src/speechflow-node-t2t-punctuation.ts +1 -1
  67. package/speechflow-cli/src/speechflow-node-t2t-sentence.ts +86 -10
  68. package/speechflow-cli/src/speechflow-node-t2t-spellcheck.ts +1 -1
  69. package/speechflow-cli/src/speechflow-node-t2t-summary.ts +1 -1
  70. package/speechflow-cli/src/speechflow-node-t2t-translate.ts +54 -29
  71. package/speechflow-ui-db/dst/index.css +1 -1
  72. package/speechflow-ui-db/dst/index.js +13 -13
  73. package/speechflow-ui-db/package.json +16 -15
  74. package/speechflow-ui-db/src/app.vue +62 -17
  75. package/speechflow-ui-st/dst/index.css +1 -1
  76. package/speechflow-ui-st/dst/index.js +32 -32
  77. package/speechflow-ui-st/package.json +17 -16
  78. package/speechflow-ui-st/src/app.vue +9 -8
@@ -121,17 +121,17 @@ export default class SpeechFlowNodeT2TOPUS extends SpeechFlowNode {
121
121
 
122
122
  /* close node */
123
123
  async close () {
124
- /* shutdown Transformers */
125
- if (this.translator !== null) {
126
- this.translator.dispose()
127
- this.translator = null
128
- }
129
-
130
124
  /* shutdown stream */
131
125
  if (this.stream !== null) {
132
126
  await util.destroyStream(this.stream)
133
127
  this.stream = null
134
128
  }
129
+
130
+ /* shutdown Transformers */
131
+ if (this.translator !== null) {
132
+ this.translator.dispose()
133
+ this.translator = null
134
+ }
135
135
  }
136
136
  }
137
137
 
@@ -5,12 +5,13 @@
5
5
  */
6
6
 
7
7
  /* standard dependencies */
8
- import Stream from "node:stream"
8
+ import Stream from "node:stream"
9
9
 
10
10
  /* external dependencies */
11
- import BadWordsNext from "bad-words-next"
12
- import en from "bad-words-next/lib/en"
13
- import de from "bad-words-next/lib/de"
11
+ import BadWordsNext from "bad-words-next"
12
+ import en from "bad-words-next/lib/en"
13
+ import de from "bad-words-next/lib/de"
14
+ import { Profanity, CensorType } from "@2toad/profanity"
14
15
 
15
16
  /* internal dependencies */
16
17
  import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
@@ -31,8 +32,7 @@ export default class SpeechFlowNodeT2TProfanity extends SpeechFlowNode {
31
32
  /* declare node configuration parameters */
32
33
  this.configure({
33
34
  lang: { type: "string", val: "en", match: /^(?:en|de)$/ },
34
- placeholder: { type: "string", val: "***" },
35
- mode: { type: "string", val: "replace", match: /^(?:replace|repeat)$/ }
35
+ placeholder: { type: "string", val: "***" }
36
36
  })
37
37
 
38
38
  /* declare node input/output format */
@@ -42,18 +42,37 @@ export default class SpeechFlowNodeT2TProfanity extends SpeechFlowNode {
42
42
 
43
43
  /* open node */
44
44
  async open () {
45
- /* create profanity filter instance */
46
- const filter = util.run("creating profanity filter", () =>
45
+ /* create profanity filter instances */
46
+ const filter1 = util.run("creating profanity filter 1", () =>
47
47
  new BadWordsNext({
48
48
  data: langData[this.params.lang],
49
49
  placeholder: this.params.placeholder,
50
- placeholderMode: this.params.mode as "replace" | "repeat"
50
+ placeholderMode: "repeat" as "replace" | "repeat"
51
51
  })
52
52
  )
53
+ const filter2 = util.run("creating profanity filter 2", () => {
54
+ const profanity = new Profanity({
55
+ languages: [ this.params.lang ],
56
+ grawlix: this.params.placeholder,
57
+ wholeWord: true
58
+ })
59
+ if (this.params.lang === "de") {
60
+ /* improve word-list for german language */
61
+ profanity.addWords([ "sex" ])
62
+ profanity.removeWords([
63
+ "verdammt", "glocke", "wahnsinn", "knochen", "fehler", "mist", "phantasievoll",
64
+ "huhn", "ziegen", "geil", "lustig", "verzögert", "schrauben", "geschlecht"
65
+ ])
66
+ }
67
+ return profanity
68
+ })
53
69
 
54
70
  /* apply profanity filtering */
55
- const censor = (text: string): string =>
56
- filter.filter(text)
71
+ const censor = (text: string): string => {
72
+ text = filter1.filter(text)
73
+ text = filter2.censor(text, CensorType.Word)
74
+ return text
75
+ }
57
76
 
58
77
  /* establish a transform stream and connect it to profanity filtering */
59
78
  this.stream = new Stream.Transform({
@@ -141,7 +141,7 @@ export default class SpeechFlowNodeT2TPunctuation extends SpeechFlowNode {
141
141
  await this.llm.open()
142
142
 
143
143
  /* provide text-to-text punctuation restoration */
144
- const llm = this.llm!
144
+ const llm = this.llm
145
145
  const punctuate = async (text: string) => {
146
146
  const cfg = this.setup[this.params.lang]
147
147
  if (!cfg)
@@ -14,13 +14,14 @@ import { Duration } from "luxon"
14
14
  import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
15
15
  import * as util from "./speechflow-util"
16
16
 
17
- /* text stream queue element */
17
+ /* text stream queue element */
18
18
  type TextQueueElement = {
19
- type: "text-frame",
20
- chunk: SpeechFlowChunk,
21
- complete?: boolean
19
+ type: "text-frame",
20
+ chunk: SpeechFlowChunk,
21
+ preview?: "pending" | "sent",
22
+ complete?: boolean
22
23
  } | {
23
- type: "text-eof"
24
+ type: "text-eof"
24
25
  }
25
26
 
26
27
  /* SpeechFlow node for sentence splitting */
@@ -35,13 +36,16 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
35
36
  private queueSend = this.queue.pointerUse("send")
36
37
  private closing = false
37
38
  private workingOffTimer: ReturnType<typeof setTimeout> | null = null
39
+ private previewTimer: ReturnType<typeof setTimeout> | null = null
38
40
 
39
41
  /* construct node */
40
42
  constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
41
43
  super(id, cfg, opts, args)
42
44
 
43
45
  /* declare node configuration parameters */
44
- this.configure({})
46
+ this.configure({
47
+ timeout: { type: "number", pos: 0, val: 3 * 1000 }
48
+ })
45
49
 
46
50
  /* declare node input/output format */
47
51
  this.input = "text"
@@ -78,6 +82,8 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
78
82
  this.queueSplit.walk(+1)
79
83
  break
80
84
  }
85
+
86
+ /* perform sentence splitting on input chunk */
81
87
  const chunk = element.chunk
82
88
  const payload = chunk.payload as string
83
89
  const m = payload.match(/^((?:.|\r?\n)+?[.;?!])\s*((?:.|\r?\n)*)$/)
@@ -115,20 +121,33 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
115
121
  if (element2 === undefined)
116
122
  break
117
123
  if (element2.type === "text-eof") {
124
+ /* no more chunks: output as final
125
+ (perhaps incomplete sentence at end of stream) */
118
126
  element.complete = true
119
127
  this.queueSplit.touch()
120
128
  this.queueSplit.walk(+1)
121
129
  break
122
130
  }
131
+
132
+ /* merge into following chunk */
123
133
  element2.chunk.timestampStart = element.chunk.timestampStart
124
134
  element2.chunk.payload =
125
135
  (element.chunk.payload as string) + " " +
126
136
  (element2.chunk.payload as string)
137
+
138
+ /* reset preview state (merged content needs new preview) */
139
+ element2.preview = undefined
127
140
  this.queueSplit.delete()
128
141
  this.queueSplit.touch()
129
142
  }
130
- else
143
+ else {
144
+ /* no following chunk yet: mark for intermediate preview output */
145
+ if (element.preview !== "sent") {
146
+ element.preview = "pending"
147
+ this.queueSplit.touch()
148
+ }
131
149
  break
150
+ }
132
151
  }
133
152
  }
134
153
 
@@ -157,8 +176,23 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
157
176
  callback(new Error("expected text input as string chunks"))
158
177
  else if (chunk.payload.length === 0)
159
178
  callback()
179
+ else if (chunk.kind === "intermediate") {
180
+ /* intermediate chunks: pass through immediately (bypass queue) */
181
+ self.log("info", `received text (${chunk.kind}): ${JSON.stringify(chunk.payload)}`)
182
+ self.log("info", `send text (intermediate pass-through): ${JSON.stringify(chunk.payload)}`)
183
+ this.push(chunk)
184
+ callback()
185
+ }
160
186
  else {
161
- self.log("info", `received text: ${JSON.stringify(chunk.payload)}`)
187
+ /* final chunks: queue for sentence splitting */
188
+ self.log("info", `received text (${chunk.kind}): ${JSON.stringify(chunk.payload)}`)
189
+
190
+ /* cancel any pending preview timeout */
191
+ if (self.previewTimer !== null) {
192
+ clearTimeout(self.previewTimer)
193
+ self.previewTimer = null
194
+ }
195
+
162
196
  self.queueRecv.append({ type: "text-frame", chunk })
163
197
  callback()
164
198
  }
@@ -192,6 +226,7 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
192
226
  else if (element !== undefined
193
227
  && element.type === "text-frame"
194
228
  && element.complete === true) {
229
+ /* send all consecutive complete chunks */
195
230
  while (true) {
196
231
  const nextElement = self.queueSend.peek()
197
232
  if (nextElement === undefined)
@@ -204,12 +239,49 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
204
239
  else if (nextElement.type === "text-frame"
205
240
  && nextElement.complete !== true)
206
241
  break
207
- self.log("info", `send text: ${JSON.stringify(nextElement.chunk.payload)}`)
242
+ self.log("info", `send text (${nextElement.chunk.kind}): ${JSON.stringify(nextElement.chunk.payload)}`)
208
243
  this.push(nextElement.chunk)
209
244
  self.queueSend.walk(+1)
210
245
  self.queue.trim()
211
246
  }
212
247
  }
248
+ else if (element !== undefined
249
+ && element.type === "text-frame"
250
+ && element.preview === "pending") {
251
+ /* send intermediate preview (without advancing pointer) */
252
+ const previewChunk = element.chunk.clone()
253
+ previewChunk.kind = "intermediate"
254
+ self.log("info", `send text (intermediate preview): ${JSON.stringify(previewChunk.payload)}`)
255
+ this.push(previewChunk)
256
+ element.preview = "sent"
257
+ self.queueSend.touch()
258
+
259
+ /* start preview timeout (if configured) */
260
+ const timeout = self.params.timeout as number
261
+ if (timeout > 0 && self.previewTimer === null) {
262
+ self.previewTimer = setTimeout(() => {
263
+ self.previewTimer = null
264
+ if (self.closing)
265
+ return
266
+
267
+ /* promote preview to final chunk */
268
+ const el = self.queueSend.peek()
269
+ if (el !== undefined
270
+ && el.type === "text-frame"
271
+ && el.preview === "sent"
272
+ && el.complete !== true) {
273
+ self.log("info", `timeout: promoting intermediate to final: ${JSON.stringify(el.chunk.payload)}`)
274
+ el.complete = true
275
+ self.queueSend.touch()
276
+ self.queue.emit("write")
277
+ }
278
+ }, timeout)
279
+ }
280
+
281
+ /* wait for more data */
282
+ if (!self.closing)
283
+ self.queue.once("write", flushPendingChunks)
284
+ }
213
285
  else if (!self.closing)
214
286
  self.queue.once("write", flushPendingChunks)
215
287
  }
@@ -223,11 +295,15 @@ export default class SpeechFlowNodeT2TSentence extends SpeechFlowNode {
223
295
  /* indicate closing */
224
296
  this.closing = true
225
297
 
226
- /* clean up timer */
298
+ /* clean up timers */
227
299
  if (this.workingOffTimer !== null) {
228
300
  clearTimeout(this.workingOffTimer)
229
301
  this.workingOffTimer = null
230
302
  }
303
+ if (this.previewTimer !== null) {
304
+ clearTimeout(this.previewTimer)
305
+ this.previewTimer = null
306
+ }
231
307
 
232
308
  /* remove any pending event listeners */
233
309
  this.queue.removeAllListeners("write")
@@ -128,7 +128,7 @@ export default class SpeechFlowNodeT2TSpellcheck extends SpeechFlowNode {
128
128
  await this.llm.open()
129
129
 
130
130
  /* provide text-to-text spellchecking */
131
- const llm = this.llm!
131
+ const llm = this.llm
132
132
  const spellcheck = async (text: string) => {
133
133
  const cfg = this.setup[this.params.lang]
134
134
  if (!cfg)
@@ -127,7 +127,7 @@ export default class SpeechFlowNodeT2TSummary extends SpeechFlowNode {
127
127
  await this.llm.open()
128
128
 
129
129
  /* provide text summarization */
130
- const llm = this.llm!
130
+ const llm = this.llm
131
131
  const summarize = async (text: string) => {
132
132
  const cfg = this.setup[this.params.lang]
133
133
  if (!cfg)
@@ -13,7 +13,7 @@ import * as util from "./speechflow-util"
13
13
  import { LLM, type LLMCompleteMessage } from "./speechflow-util-llm"
14
14
 
15
15
  /* internal utility types */
16
- type ConfigEntry = { systemPrompt: string, chat: LLMCompleteMessage[] }
16
+ type ConfigEntry = { systemPrompt: { [ type: string ]: string }, chat: LLMCompleteMessage[] }
17
17
  type Config = { [ key: string ]: ConfigEntry }
18
18
 
19
19
  /* SpeechFlow node for LLM-based text-to-text translation */
@@ -28,19 +28,30 @@ export default class SpeechFlowNodeT2TTranslate extends SpeechFlowNode {
28
28
  private setup: Config = {
29
29
  /* English (EN) to German (DE) translation */
30
30
  "en-de": {
31
- systemPrompt:
32
- "You are a translator.\n" +
33
- "Output only the requested text.\n" +
34
- "Do not use markdown.\n" +
35
- "Do not chat.\n" +
36
- "Do not show any explanations.\n" +
37
- "Do not show any introduction.\n" +
38
- "Do not show any preamble.\n" +
39
- "Do not show any prolog.\n" +
40
- "Do not show any epilog.\n" +
41
- "Get to the point.\n" +
42
- "Preserve the original meaning, tone, and nuance.\n" +
43
- "Directly translate text from English (EN) to fluent and natural German (DE) language.\n",
31
+ systemPrompt: {
32
+ "any":
33
+ "You are a translator.\n" +
34
+ "Output only the requested text.\n" +
35
+ "Do not use markdown.\n" +
36
+ "Do not chat.\n" +
37
+ "Do not show any explanations.\n" +
38
+ "Do not show any introduction.\n" +
39
+ "Do not show any preamble.\n" +
40
+ "Do not show any prolog.\n" +
41
+ "Do not show any epilog.\n" +
42
+ "Get to the point.\n" +
43
+ "Preserve the original meaning, tone, and nuance.\n" +
44
+ "Directly translate text from English (EN) to fluent and natural German (DE) language.\n",
45
+ "translategemma":
46
+ /* ATTENTION: do not change this prompt, as TranslateGemma requires this fixed format! */
47
+ "You are a professional English (en) to German (de) translator. " +
48
+ "Your goal is to accurately convey the meaning and nuances of the original " +
49
+ "English text while adhering to German grammar, vocabulary, and cultural sensitivities. " +
50
+ "Produce only the German translation, without any additional explanations or commentary. " +
51
+ "Please translate the following English text into German:\n" +
52
+ "\n" +
53
+ "\n"
54
+ },
44
55
  chat: [
45
56
  { role: "user", content: "I love my wife." },
46
57
  { role: "assistant", content: "Ich liebe meine Frau." },
@@ -53,19 +64,30 @@ export default class SpeechFlowNodeT2TTranslate extends SpeechFlowNode {
53
64
 
54
65
  /* German (DE) to English (EN) translation */
55
66
  "de-en": {
56
- systemPrompt:
57
- "You are a translator.\n" +
58
- "Output only the requested text.\n" +
59
- "Do not use markdown.\n" +
60
- "Do not chat.\n" +
61
- "Do not show any explanations.\n" +
62
- "Do not show any introduction.\n" +
63
- "Do not show any preamble.\n" +
64
- "Do not show any prolog.\n" +
65
- "Do not show any epilog.\n" +
66
- "Get to the point.\n" +
67
- "Preserve the original meaning, tone, and nuance.\n" +
68
- "Directly translate text from German (DE) to fluent and natural English (EN) language.\n",
67
+ systemPrompt: {
68
+ "any":
69
+ "You are a translator.\n" +
70
+ "Output only the requested text.\n" +
71
+ "Do not use markdown.\n" +
72
+ "Do not chat.\n" +
73
+ "Do not show any explanations.\n" +
74
+ "Do not show any introduction.\n" +
75
+ "Do not show any preamble.\n" +
76
+ "Do not show any prolog.\n" +
77
+ "Do not show any epilog.\n" +
78
+ "Get to the point.\n" +
79
+ "Preserve the original meaning, tone, and nuance.\n" +
80
+ "Directly translate text from German (DE) to fluent and natural English (EN) language.\n",
81
+ "translategemma":
82
+ /* ATTENTION: do not change this prompt, as TranslateGemma requires this fixed format! */
83
+ "You are a professional German (de) to English (en) translator. " +
84
+ "Your goal is to accurately convey the meaning and nuances of the original " +
85
+ "German text while adhering to English grammar, vocabulary, and cultural sensitivities. " +
86
+ "Produce only the English translation, without any additional explanations or commentary. " +
87
+ "Please translate the following German text into English:\n" +
88
+ "\n" +
89
+ "\n"
90
+ },
69
91
  chat: [
70
92
  { role: "user", content: "Ich liebe meine Frau." },
71
93
  { role: "assistant", content: "I love my wife." },
@@ -120,14 +142,17 @@ export default class SpeechFlowNodeT2TTranslate extends SpeechFlowNode {
120
142
  await this.llm.open()
121
143
 
122
144
  /* provide text-to-text translation */
123
- const llm = this.llm!
145
+ const llm = this.llm
124
146
  const translate = async (text: string) => {
125
147
  const key = `${this.params.src}-${this.params.dst}`
126
148
  const cfg = this.setup[key]
127
149
  if (!cfg)
128
150
  throw new Error(`unsupported language pair: ${key}`)
151
+ let systemPrompt = cfg.systemPrompt["any"]
152
+ if (this.params.model.match(/^translategemma/))
153
+ systemPrompt = cfg.systemPrompt["translategemma"]
129
154
  return llm.complete({
130
- system: cfg.systemPrompt,
155
+ system: systemPrompt,
131
156
  messages: cfg.chat,
132
157
  prompt: text
133
158
  })