speechflow 1.7.1 → 2.0.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 (99) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +387 -119
  3. package/etc/claude.md +5 -5
  4. package/etc/speechflow.yaml +2 -2
  5. package/package.json +3 -3
  6. package/speechflow-cli/dst/speechflow-main-graph.d.ts +1 -0
  7. package/speechflow-cli/dst/speechflow-main-graph.js +28 -5
  8. package/speechflow-cli/dst/speechflow-main-graph.js.map +1 -1
  9. package/speechflow-cli/dst/speechflow-node-a2a-wav.js +24 -4
  10. package/speechflow-cli/dst/speechflow-node-a2a-wav.js.map +1 -1
  11. package/speechflow-cli/dst/speechflow-node-a2t-google.d.ts +17 -0
  12. package/speechflow-cli/dst/speechflow-node-a2t-google.js +320 -0
  13. package/speechflow-cli/dst/speechflow-node-a2t-google.js.map +1 -0
  14. package/speechflow-cli/dst/speechflow-node-t2a-google.d.ts +15 -0
  15. package/speechflow-cli/dst/speechflow-node-t2a-google.js +218 -0
  16. package/speechflow-cli/dst/speechflow-node-t2a-google.js.map +1 -0
  17. package/speechflow-cli/dst/speechflow-node-t2a-openai.d.ts +15 -0
  18. package/speechflow-cli/dst/speechflow-node-t2a-openai.js +195 -0
  19. package/speechflow-cli/dst/speechflow-node-t2a-openai.js.map +1 -0
  20. package/speechflow-cli/dst/speechflow-node-t2a-supertonic.d.ts +17 -0
  21. package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js +608 -0
  22. package/speechflow-cli/dst/speechflow-node-t2a-supertonic.js.map +1 -0
  23. package/speechflow-cli/dst/speechflow-node-t2t-amazon.js.map +1 -1
  24. package/speechflow-cli/dst/{speechflow-node-t2t-transformers.d.ts → speechflow-node-t2t-opus.d.ts} +1 -3
  25. package/speechflow-cli/dst/speechflow-node-t2t-opus.js +159 -0
  26. package/speechflow-cli/dst/speechflow-node-t2t-opus.js.map +1 -0
  27. package/speechflow-cli/dst/speechflow-node-t2t-profanity.d.ts +11 -0
  28. package/speechflow-cli/dst/speechflow-node-t2t-profanity.js +118 -0
  29. package/speechflow-cli/dst/speechflow-node-t2t-profanity.js.map +1 -0
  30. package/speechflow-cli/dst/speechflow-node-t2t-punctuation.d.ts +13 -0
  31. package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js +220 -0
  32. package/speechflow-cli/dst/speechflow-node-t2t-punctuation.js.map +1 -0
  33. package/speechflow-cli/dst/{speechflow-node-t2t-openai.d.ts → speechflow-node-t2t-spellcheck.d.ts} +2 -2
  34. package/speechflow-cli/dst/{speechflow-node-t2t-openai.js → speechflow-node-t2t-spellcheck.js} +47 -99
  35. package/speechflow-cli/dst/speechflow-node-t2t-spellcheck.js.map +1 -0
  36. package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +3 -6
  37. package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -1
  38. package/speechflow-cli/dst/speechflow-node-t2t-summary.d.ts +16 -0
  39. package/speechflow-cli/dst/speechflow-node-t2t-summary.js +241 -0
  40. package/speechflow-cli/dst/speechflow-node-t2t-summary.js.map +1 -0
  41. package/speechflow-cli/dst/{speechflow-node-t2t-ollama.d.ts → speechflow-node-t2t-translate.d.ts} +2 -2
  42. package/speechflow-cli/dst/{speechflow-node-t2t-transformers.js → speechflow-node-t2t-translate.js} +53 -115
  43. package/speechflow-cli/dst/speechflow-node-t2t-translate.js.map +1 -0
  44. package/speechflow-cli/dst/speechflow-node-xio-exec.d.ts +12 -0
  45. package/speechflow-cli/dst/speechflow-node-xio-exec.js +223 -0
  46. package/speechflow-cli/dst/speechflow-node-xio-exec.js.map +1 -0
  47. package/speechflow-cli/dst/speechflow-node-xio-file.d.ts +1 -0
  48. package/speechflow-cli/dst/speechflow-node-xio-file.js +79 -66
  49. package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -1
  50. package/speechflow-cli/dst/speechflow-node-xio-vban.d.ts +17 -0
  51. package/speechflow-cli/dst/speechflow-node-xio-vban.js +330 -0
  52. package/speechflow-cli/dst/speechflow-node-xio-vban.js.map +1 -0
  53. package/speechflow-cli/dst/speechflow-node-xio-webrtc.d.ts +39 -0
  54. package/speechflow-cli/dst/speechflow-node-xio-webrtc.js +500 -0
  55. package/speechflow-cli/dst/speechflow-node-xio-webrtc.js.map +1 -0
  56. package/speechflow-cli/dst/speechflow-util-audio.js +4 -5
  57. package/speechflow-cli/dst/speechflow-util-audio.js.map +1 -1
  58. package/speechflow-cli/dst/speechflow-util-error.d.ts +1 -0
  59. package/speechflow-cli/dst/speechflow-util-error.js +5 -0
  60. package/speechflow-cli/dst/speechflow-util-error.js.map +1 -1
  61. package/speechflow-cli/dst/speechflow-util-llm.d.ts +35 -0
  62. package/speechflow-cli/dst/speechflow-util-llm.js +363 -0
  63. package/speechflow-cli/dst/speechflow-util-llm.js.map +1 -0
  64. package/speechflow-cli/dst/speechflow-util.d.ts +1 -0
  65. package/speechflow-cli/dst/speechflow-util.js +1 -0
  66. package/speechflow-cli/dst/speechflow-util.js.map +1 -1
  67. package/speechflow-cli/etc/oxlint.jsonc +2 -1
  68. package/speechflow-cli/package.json +34 -17
  69. package/speechflow-cli/src/lib.d.ts +5 -0
  70. package/speechflow-cli/src/speechflow-main-graph.ts +31 -5
  71. package/speechflow-cli/src/speechflow-node-a2a-wav.ts +24 -4
  72. package/speechflow-cli/src/speechflow-node-a2t-google.ts +322 -0
  73. package/speechflow-cli/src/speechflow-node-t2a-google.ts +206 -0
  74. package/speechflow-cli/src/speechflow-node-t2a-openai.ts +179 -0
  75. package/speechflow-cli/src/speechflow-node-t2a-supertonic.ts +701 -0
  76. package/speechflow-cli/src/speechflow-node-t2t-amazon.ts +2 -1
  77. package/speechflow-cli/src/speechflow-node-t2t-opus.ts +136 -0
  78. package/speechflow-cli/src/speechflow-node-t2t-profanity.ts +93 -0
  79. package/speechflow-cli/src/speechflow-node-t2t-punctuation.ts +201 -0
  80. package/speechflow-cli/src/{speechflow-node-t2t-openai.ts → speechflow-node-t2t-spellcheck.ts} +48 -107
  81. package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +3 -6
  82. package/speechflow-cli/src/speechflow-node-t2t-summary.ts +229 -0
  83. package/speechflow-cli/src/speechflow-node-t2t-translate.ts +181 -0
  84. package/speechflow-cli/src/speechflow-node-xio-exec.ts +210 -0
  85. package/speechflow-cli/src/speechflow-node-xio-file.ts +92 -79
  86. package/speechflow-cli/src/speechflow-node-xio-vban.ts +325 -0
  87. package/speechflow-cli/src/speechflow-node-xio-webrtc.ts +533 -0
  88. package/speechflow-cli/src/speechflow-util-audio.ts +5 -5
  89. package/speechflow-cli/src/speechflow-util-error.ts +9 -0
  90. package/speechflow-cli/src/speechflow-util-llm.ts +367 -0
  91. package/speechflow-cli/src/speechflow-util.ts +1 -0
  92. package/speechflow-ui-db/package.json +9 -9
  93. package/speechflow-ui-st/package.json +9 -9
  94. package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +0 -293
  95. package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +0 -1
  96. package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +0 -1
  97. package/speechflow-cli/dst/speechflow-node-t2t-transformers.js.map +0 -1
  98. package/speechflow-cli/src/speechflow-node-t2t-ollama.ts +0 -281
  99. package/speechflow-cli/src/speechflow-node-t2t-transformers.ts +0 -247
@@ -1,293 +0,0 @@
1
- "use strict";
2
- /*
3
- ** SpeechFlow - Speech Processing Flow Graph
4
- ** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
5
- ** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
6
- */
7
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
- if (k2 === undefined) k2 = k;
9
- var desc = Object.getOwnPropertyDescriptor(m, k);
10
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
- desc = { enumerable: true, get: function() { return m[k]; } };
12
- }
13
- Object.defineProperty(o, k2, desc);
14
- }) : (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- o[k2] = m[k];
17
- }));
18
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
- Object.defineProperty(o, "default", { enumerable: true, value: v });
20
- }) : function(o, v) {
21
- o["default"] = v;
22
- });
23
- var __importStar = (this && this.__importStar) || (function () {
24
- var ownKeys = function(o) {
25
- ownKeys = Object.getOwnPropertyNames || function (o) {
26
- var ar = [];
27
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
- return ar;
29
- };
30
- return ownKeys(o);
31
- };
32
- return function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- })();
40
- var __importDefault = (this && this.__importDefault) || function (mod) {
41
- return (mod && mod.__esModule) ? mod : { "default": mod };
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- /* standard dependencies */
45
- const node_stream_1 = __importDefault(require("node:stream"));
46
- /* external dependencies */
47
- const ollama_1 = require("ollama");
48
- /* internal dependencies */
49
- const speechflow_node_1 = __importDefault(require("./speechflow-node"));
50
- const util = __importStar(require("./speechflow-util"));
51
- /* SpeechFlow node for Ollama text-to-text translation */
52
- class SpeechFlowNodeT2TOllama extends speechflow_node_1.default {
53
- /* declare official node name */
54
- static name = "t2t-ollama";
55
- /* internal state */
56
- ollama = null;
57
- /* internal LLM setup */
58
- setup = {
59
- /* English (EN) spellchecking only */
60
- "en-en": {
61
- systemPrompt: "You are a proofreader and spellchecker for English.\n" +
62
- "Output only the corrected text.\n" +
63
- "Do NOT use markdown.\n" +
64
- "Do NOT give any explanations.\n" +
65
- "Do NOT give any introduction.\n" +
66
- "Do NOT give any comments.\n" +
67
- "Do NOT give any preamble.\n" +
68
- "Do NOT give any prolog.\n" +
69
- "Do NOT give any epilog.\n" +
70
- "Do NOT change the grammar.\n" +
71
- "Do NOT use synonyms for words.\n" +
72
- "Keep all words.\n" +
73
- "Fill in missing commas.\n" +
74
- "Fill in missing points.\n" +
75
- "Fill in missing question marks.\n" +
76
- "Fill in missing hyphens.\n" +
77
- "Focus ONLY on the word spelling.\n" +
78
- "The text you have to correct is:\n",
79
- chat: [
80
- { role: "user", content: "I luve my wyfe" },
81
- { role: "assistant", content: "I love my wife." },
82
- { role: "user", content: "The weether is wunderfull!" },
83
- { role: "assistant", content: "The weather is wonderful!" },
84
- { role: "user", content: "The life awesome but I'm hungry." },
85
- { role: "assistant", content: "The life is awesome, but I'm hungry." }
86
- ]
87
- },
88
- /* German (DE) spellchecking only */
89
- "de-de": {
90
- systemPrompt: "Du bist ein Korrekturleser und Rechtschreibprüfer für Deutsch.\n" +
91
- "Gib nur den korrigierten Text aus.\n" +
92
- "Benutze KEIN Markdown.\n" +
93
- "Gib KEINE Erklärungen.\n" +
94
- "Gib KEINE Einleitung.\n" +
95
- "Gib KEINE Kommentare.\n" +
96
- "Gib KEINE Preamble.\n" +
97
- "Gib KEINEN Prolog.\n" +
98
- "Gib KEINEN Epilog.\n" +
99
- "Ändere NICHT die Grammatik.\n" +
100
- "Verwende KEINE Synonyme für Wörter.\n" +
101
- "Behalte alle Wörter bei.\n" +
102
- "Füge fehlende Kommas ein.\n" +
103
- "Füge fehlende Punkte ein.\n" +
104
- "Füge fehlende Fragezeichen ein.\n" +
105
- "Füge fehlende Bindestriche ein.\n" +
106
- "Füge fehlende Gedankenstriche ein.\n" +
107
- "Fokussiere dich NUR auf die Rechtschreibung der Wörter.\n" +
108
- "Der von dir zu korrigierende Text ist:\n",
109
- chat: [
110
- { role: "user", content: "Ich ljebe meine Frao" },
111
- { role: "assistant", content: "Ich liebe meine Frau." },
112
- { role: "user", content: "Die Wedter ist wunderschoen." },
113
- { role: "assistant", content: "Das Wetter ist wunderschön." },
114
- { role: "user", content: "Das Leben einfach großartig aber ich bin hungrig." },
115
- { role: "assistant", content: "Das Leben ist einfach großartig, aber ich bin hungrig." }
116
- ]
117
- },
118
- /* English (EN) to German (DE) translation */
119
- "en-de": {
120
- systemPrompt: "You are a translator.\n" +
121
- "Output only the requested text.\n" +
122
- "Do not use markdown.\n" +
123
- "Do not chat.\n" +
124
- "Do not show any explanations.\n" +
125
- "Do not show any introduction.\n" +
126
- "Do not show any preamble.\n" +
127
- "Do not show any prolog.\n" +
128
- "Do not show any epilog.\n" +
129
- "Get to the point.\n" +
130
- "Preserve the original meaning, tone, and nuance.\n" +
131
- "Directly translate text from English (EN) to fluent and natural German (DE) language.\n",
132
- chat: [
133
- { role: "user", content: "I love my wife." },
134
- { role: "assistant", content: "Ich liebe meine Frau." },
135
- { role: "user", content: "The weather is wonderful." },
136
- { role: "assistant", content: "Das Wetter ist wunderschön." },
137
- { role: "user", content: "The life is awesome." },
138
- { role: "assistant", content: "Das Leben ist einfach großartig." }
139
- ]
140
- },
141
- /* German (DE) to English (EN) translation */
142
- "de-en": {
143
- systemPrompt: "You are a translator.\n" +
144
- "Output only the requested text.\n" +
145
- "Do not use markdown.\n" +
146
- "Do not chat.\n" +
147
- "Do not show any explanations.\n" +
148
- "Do not show any introduction.\n" +
149
- "Do not show any preamble.\n" +
150
- "Do not show any prolog.\n" +
151
- "Do not show any epilog.\n" +
152
- "Get to the point.\n" +
153
- "Preserve the original meaning, tone, and nuance.\n" +
154
- "Directly translate text from German (DE) to fluent and natural English (EN) language.\n",
155
- chat: [
156
- { role: "user", content: "Ich liebe meine Frau." },
157
- { role: "assistant", content: "I love my wife." },
158
- { role: "user", content: "Das Wetter ist wunderschön." },
159
- { role: "assistant", content: "The weather is wonderful." },
160
- { role: "user", content: "Das Leben ist einfach großartig." },
161
- { role: "assistant", content: "The life is awesome." }
162
- ]
163
- }
164
- };
165
- /* construct node */
166
- constructor(id, cfg, opts, args) {
167
- super(id, cfg, opts, args);
168
- /* declare node configuration parameters */
169
- this.configure({
170
- api: { type: "string", val: "http://127.0.0.1:11434", match: /^https?:\/\/.+?:\d+$/ },
171
- model: { type: "string", val: "gemma3:4b-it-q4_K_M", match: /^.+$/ },
172
- src: { type: "string", pos: 0, val: "de", match: /^(?:de|en)$/ },
173
- dst: { type: "string", pos: 1, val: "en", match: /^(?:de|en)$/ }
174
- });
175
- /* tell effective mode */
176
- if (this.params.src === this.params.dst)
177
- this.log("info", `Ollama: operation mode: spellchecking for language "${this.params.src}"`);
178
- else
179
- this.log("info", `Ollama: operation mode: translation from language "${this.params.src}"` +
180
- ` to language "${this.params.dst}"`);
181
- /* declare node input/output format */
182
- this.input = "text";
183
- this.output = "text";
184
- }
185
- /* open node */
186
- async open() {
187
- /* instantiate Ollama API */
188
- this.ollama = new ollama_1.Ollama({ host: this.params.api });
189
- /* ensure the model is available */
190
- let models;
191
- try {
192
- models = await this.ollama.list();
193
- }
194
- catch (err) {
195
- throw new Error(`failed to connect to Ollama API at ${this.params.api}: ${err}`, { cause: err });
196
- }
197
- const exists = models.models.some((m) => m.name === this.params.model);
198
- if (!exists) {
199
- this.log("info", `Ollama: model "${this.params.model}" still not present in Ollama -- ` +
200
- "automatically downloading model");
201
- let artifact = "";
202
- let percent = 0;
203
- let lastLoggedPercent = -1;
204
- const interval = setInterval(() => {
205
- if (percent !== lastLoggedPercent) {
206
- this.log("info", `downloaded ${percent.toFixed(2)}% of artifact "${artifact}"`);
207
- lastLoggedPercent = percent;
208
- }
209
- }, 1000);
210
- try {
211
- const progress = await this.ollama.pull({ model: this.params.model, stream: true });
212
- for await (const event of progress) {
213
- if (event.digest)
214
- artifact = event.digest;
215
- if (event.completed && event.total)
216
- percent = (event.completed / event.total) * 100;
217
- }
218
- }
219
- finally {
220
- clearInterval(interval);
221
- }
222
- }
223
- else
224
- this.log("info", `Ollama: model "${this.params.model}" already present in Ollama`);
225
- /* provide text-to-text translation */
226
- const translate = async (text) => {
227
- const key = `${this.params.src}-${this.params.dst}`;
228
- const cfg = this.setup[key];
229
- const response = await this.ollama.chat({
230
- model: this.params.model,
231
- messages: [
232
- { role: "system", content: cfg.systemPrompt },
233
- ...cfg.chat,
234
- { role: "user", content: text }
235
- ],
236
- keep_alive: "10m",
237
- options: {
238
- repeat_penalty: 1.1,
239
- temperature: 0.7,
240
- seed: 1,
241
- top_k: 10,
242
- top_p: 0.5
243
- }
244
- });
245
- return response.message.content;
246
- };
247
- /* establish a duplex stream and connect it to Ollama */
248
- this.stream = new node_stream_1.default.Transform({
249
- readableObjectMode: true,
250
- writableObjectMode: true,
251
- decodeStrings: false,
252
- highWaterMark: 1,
253
- transform(chunk, encoding, callback) {
254
- if (Buffer.isBuffer(chunk.payload))
255
- callback(new Error("invalid chunk payload type"));
256
- else {
257
- if (chunk.payload === "") {
258
- this.push(chunk);
259
- callback();
260
- }
261
- else {
262
- translate(chunk.payload).then((payload) => {
263
- const chunkNew = chunk.clone();
264
- chunkNew.payload = payload;
265
- this.push(chunkNew);
266
- callback();
267
- }).catch((error) => {
268
- callback(util.ensureError(error));
269
- });
270
- }
271
- }
272
- },
273
- final(callback) {
274
- callback();
275
- }
276
- });
277
- }
278
- /* close node */
279
- async close() {
280
- /* shutdown stream */
281
- if (this.stream !== null) {
282
- await util.destroyStream(this.stream);
283
- this.stream = null;
284
- }
285
- /* shutdown Ollama */
286
- if (this.ollama !== null) {
287
- this.ollama.abort();
288
- this.ollama = null;
289
- }
290
- }
291
- }
292
- exports.default = SpeechFlowNodeT2TOllama;
293
- //# sourceMappingURL=speechflow-node-t2t-ollama.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"speechflow-node-t2t-ollama.js","sourceRoot":"","sources":["../src/speechflow-node-t2t-ollama.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEF,6BAA6B;AAC7B,8DAAoC;AAEpC,6BAA6B;AAC7B,mCAAkD;AAElD,6BAA6B;AAC7B,wEAAmE;AACnE,wDAAmE;AAMnE,2DAA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AM,CAAC,CAAA;YACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QACtB,CAAC;QAED,6BAA6B;QAC7B,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC3B,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAA;YACzB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;QAC1B,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;YACxB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA;QACzB,CAAC;IACL,CAAC;;AA9NL,gDA+NC"}
@@ -1,281 +0,0 @@
1
- /*
2
- ** SpeechFlow - Speech Processing Flow Graph
3
- ** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
4
- ** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
5
- */
6
-
7
- /* standard dependencies */
8
- import Stream from "node:stream"
9
-
10
- /* external dependencies */
11
- import { Ollama, type ListResponse } from "ollama"
12
-
13
- /* internal dependencies */
14
- import SpeechFlowNode, { SpeechFlowChunk } from "./speechflow-node"
15
- import * as util from "./speechflow-util"
16
-
17
- /* internal utility types */
18
- type ConfigEntry = { systemPrompt: string, chat: Array<{ role: string, content: string }> }
19
- type Config = { [ key: string ]: ConfigEntry }
20
-
21
- /* SpeechFlow node for Ollama text-to-text translation */
22
- export default class SpeechFlowNodeT2TOllama extends SpeechFlowNode {
23
- /* declare official node name */
24
- public static name = "t2t-ollama"
25
-
26
- /* internal state */
27
- private ollama: Ollama | null = null
28
-
29
- /* internal LLM setup */
30
- private setup: Config = {
31
- /* English (EN) spellchecking only */
32
- "en-en": {
33
- systemPrompt:
34
- "You are a proofreader and spellchecker for English.\n" +
35
- "Output only the corrected text.\n" +
36
- "Do NOT use markdown.\n" +
37
- "Do NOT give any explanations.\n" +
38
- "Do NOT give any introduction.\n" +
39
- "Do NOT give any comments.\n" +
40
- "Do NOT give any preamble.\n" +
41
- "Do NOT give any prolog.\n" +
42
- "Do NOT give any epilog.\n" +
43
- "Do NOT change the grammar.\n" +
44
- "Do NOT use synonyms for words.\n" +
45
- "Keep all words.\n" +
46
- "Fill in missing commas.\n" +
47
- "Fill in missing points.\n" +
48
- "Fill in missing question marks.\n" +
49
- "Fill in missing hyphens.\n" +
50
- "Focus ONLY on the word spelling.\n" +
51
- "The text you have to correct is:\n",
52
- chat: [
53
- { role: "user", content: "I luve my wyfe" },
54
- { role: "assistant", content: "I love my wife." },
55
- { role: "user", content: "The weether is wunderfull!" },
56
- { role: "assistant", content: "The weather is wonderful!" },
57
- { role: "user", content: "The life awesome but I'm hungry." },
58
- { role: "assistant", content: "The life is awesome, but I'm hungry." }
59
- ]
60
- },
61
-
62
- /* German (DE) spellchecking only */
63
- "de-de": {
64
- systemPrompt:
65
- "Du bist ein Korrekturleser und Rechtschreibprüfer für Deutsch.\n" +
66
- "Gib nur den korrigierten Text aus.\n" +
67
- "Benutze KEIN Markdown.\n" +
68
- "Gib KEINE Erklärungen.\n" +
69
- "Gib KEINE Einleitung.\n" +
70
- "Gib KEINE Kommentare.\n" +
71
- "Gib KEINE Preamble.\n" +
72
- "Gib KEINEN Prolog.\n" +
73
- "Gib KEINEN Epilog.\n" +
74
- "Ändere NICHT die Grammatik.\n" +
75
- "Verwende KEINE Synonyme für Wörter.\n" +
76
- "Behalte alle Wörter bei.\n" +
77
- "Füge fehlende Kommas ein.\n" +
78
- "Füge fehlende Punkte ein.\n" +
79
- "Füge fehlende Fragezeichen ein.\n" +
80
- "Füge fehlende Bindestriche ein.\n" +
81
- "Füge fehlende Gedankenstriche ein.\n" +
82
- "Fokussiere dich NUR auf die Rechtschreibung der Wörter.\n" +
83
- "Der von dir zu korrigierende Text ist:\n",
84
- chat: [
85
- { role: "user", content: "Ich ljebe meine Frao" },
86
- { role: "assistant", content: "Ich liebe meine Frau." },
87
- { role: "user", content: "Die Wedter ist wunderschoen." },
88
- { role: "assistant", content: "Das Wetter ist wunderschön." },
89
- { role: "user", content: "Das Leben einfach großartig aber ich bin hungrig." },
90
- { role: "assistant", content: "Das Leben ist einfach großartig, aber ich bin hungrig." }
91
- ]
92
- },
93
-
94
- /* English (EN) to German (DE) translation */
95
- "en-de": {
96
- systemPrompt:
97
- "You are a translator.\n" +
98
- "Output only the requested text.\n" +
99
- "Do not use markdown.\n" +
100
- "Do not chat.\n" +
101
- "Do not show any explanations.\n" +
102
- "Do not show any introduction.\n" +
103
- "Do not show any preamble.\n" +
104
- "Do not show any prolog.\n" +
105
- "Do not show any epilog.\n" +
106
- "Get to the point.\n" +
107
- "Preserve the original meaning, tone, and nuance.\n" +
108
- "Directly translate text from English (EN) to fluent and natural German (DE) language.\n",
109
- chat: [
110
- { role: "user", content: "I love my wife." },
111
- { role: "assistant", content: "Ich liebe meine Frau." },
112
- { role: "user", content: "The weather is wonderful." },
113
- { role: "assistant", content: "Das Wetter ist wunderschön." },
114
- { role: "user", content: "The life is awesome." },
115
- { role: "assistant", content: "Das Leben ist einfach großartig." }
116
- ]
117
- },
118
-
119
- /* German (DE) to English (EN) translation */
120
- "de-en": {
121
- systemPrompt:
122
- "You are a translator.\n" +
123
- "Output only the requested text.\n" +
124
- "Do not use markdown.\n" +
125
- "Do not chat.\n" +
126
- "Do not show any explanations.\n" +
127
- "Do not show any introduction.\n" +
128
- "Do not show any preamble.\n" +
129
- "Do not show any prolog.\n" +
130
- "Do not show any epilog.\n" +
131
- "Get to the point.\n" +
132
- "Preserve the original meaning, tone, and nuance.\n" +
133
- "Directly translate text from German (DE) to fluent and natural English (EN) language.\n",
134
- chat: [
135
- { role: "user", content: "Ich liebe meine Frau." },
136
- { role: "assistant", content: "I love my wife." },
137
- { role: "user", content: "Das Wetter ist wunderschön." },
138
- { role: "assistant", content: "The weather is wonderful." },
139
- { role: "user", content: "Das Leben ist einfach großartig." },
140
- { role: "assistant", content: "The life is awesome." }
141
- ]
142
- }
143
- }
144
-
145
- /* construct node */
146
- constructor (id: string, cfg: { [ id: string ]: any }, opts: { [ id: string ]: any }, args: any[]) {
147
- super(id, cfg, opts, args)
148
-
149
- /* declare node configuration parameters */
150
- this.configure({
151
- api: { type: "string", val: "http://127.0.0.1:11434", match: /^https?:\/\/.+?:\d+$/ },
152
- model: { type: "string", val: "gemma3:4b-it-q4_K_M", match: /^.+$/ },
153
- src: { type: "string", pos: 0, val: "de", match: /^(?:de|en)$/ },
154
- dst: { type: "string", pos: 1, val: "en", match: /^(?:de|en)$/ }
155
- })
156
-
157
- /* tell effective mode */
158
- if (this.params.src === this.params.dst)
159
- this.log("info", `Ollama: operation mode: spellchecking for language "${this.params.src}"`)
160
- else
161
- this.log("info", `Ollama: operation mode: translation from language "${this.params.src}"` +
162
- ` to language "${this.params.dst}"`)
163
-
164
- /* declare node input/output format */
165
- this.input = "text"
166
- this.output = "text"
167
- }
168
-
169
- /* open node */
170
- async open () {
171
- /* instantiate Ollama API */
172
- this.ollama = new Ollama({ host: this.params.api })
173
-
174
- /* ensure the model is available */
175
- let models: ListResponse
176
- try {
177
- models = await this.ollama.list()
178
- }
179
- catch (err) {
180
- throw new Error(`failed to connect to Ollama API at ${this.params.api}: ${err}`, { cause: err })
181
- }
182
- const exists = models.models.some((m) => m.name === this.params.model)
183
- if (!exists) {
184
- this.log("info", `Ollama: model "${this.params.model}" still not present in Ollama -- ` +
185
- "automatically downloading model")
186
- let artifact = ""
187
- let percent = 0
188
- let lastLoggedPercent = -1
189
- const interval = setInterval(() => {
190
- if (percent !== lastLoggedPercent) {
191
- this.log("info", `downloaded ${percent.toFixed(2)}% of artifact "${artifact}"`)
192
- lastLoggedPercent = percent
193
- }
194
- }, 1000)
195
- try {
196
- const progress = await this.ollama.pull({ model: this.params.model, stream: true })
197
- for await (const event of progress) {
198
- if (event.digest)
199
- artifact = event.digest
200
- if (event.completed && event.total)
201
- percent = (event.completed / event.total) * 100
202
- }
203
- }
204
- finally {
205
- clearInterval(interval)
206
- }
207
- }
208
- else
209
- this.log("info", `Ollama: model "${this.params.model}" already present in Ollama`)
210
-
211
- /* provide text-to-text translation */
212
- const translate = async (text: string) => {
213
- const key = `${this.params.src}-${this.params.dst}`
214
- const cfg = this.setup[key]
215
- const response = await this.ollama!.chat({
216
- model: this.params.model,
217
- messages: [
218
- { role: "system", content: cfg.systemPrompt },
219
- ...cfg.chat,
220
- { role: "user", content: text }
221
- ],
222
- keep_alive: "10m",
223
- options: {
224
- repeat_penalty: 1.1,
225
- temperature: 0.7,
226
- seed: 1,
227
- top_k: 10,
228
- top_p: 0.5
229
- }
230
- })
231
- return response.message.content
232
- }
233
-
234
- /* establish a duplex stream and connect it to Ollama */
235
- this.stream = new Stream.Transform({
236
- readableObjectMode: true,
237
- writableObjectMode: true,
238
- decodeStrings: false,
239
- highWaterMark: 1,
240
- transform (chunk: SpeechFlowChunk, encoding, callback) {
241
- if (Buffer.isBuffer(chunk.payload))
242
- callback(new Error("invalid chunk payload type"))
243
- else {
244
- if (chunk.payload === "") {
245
- this.push(chunk)
246
- callback()
247
- }
248
- else {
249
- translate(chunk.payload).then((payload) => {
250
- const chunkNew = chunk.clone()
251
- chunkNew.payload = payload
252
- this.push(chunkNew)
253
- callback()
254
- }).catch((error: unknown) => {
255
- callback(util.ensureError(error))
256
- })
257
- }
258
- }
259
- },
260
- final (callback) {
261
- callback()
262
- }
263
- })
264
- }
265
-
266
- /* close node */
267
- async close () {
268
- /* shutdown stream */
269
- if (this.stream !== null) {
270
- await util.destroyStream(this.stream)
271
- this.stream = null
272
- }
273
-
274
- /* shutdown Ollama */
275
- if (this.ollama !== null) {
276
- this.ollama.abort()
277
- this.ollama = null
278
- }
279
- }
280
- }
281
-