@gringow/gringow 0.0.6 → 0.0.7

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 (104) hide show
  1. package/dist/browser.d.mts +6 -0
  2. package/dist/browser.mjs +28 -0
  3. package/dist/config.d.mts +44 -0
  4. package/dist/config.mjs +154 -0
  5. package/dist/data/check-cache.d.mts +9 -0
  6. package/dist/data/check-cache.mjs +430 -0
  7. package/dist/data/clear-cache.d.mts +3 -0
  8. package/dist/data/clear-cache.mjs +379 -0
  9. package/dist/data/create-cache-dir.d.mts +3 -0
  10. package/dist/data/create-cache-dir.mjs +361 -0
  11. package/{src/data/create-cache-id.ts → dist/data/create-cache-id.d.mts} +3 -7
  12. package/dist/data/create-cache-id.mjs +10 -0
  13. package/dist/data/delete-cache-item.d.mts +9 -0
  14. package/dist/data/delete-cache-item.mjs +411 -0
  15. package/dist/data/get-cache.d.mts +3 -0
  16. package/dist/data/get-cache.mjs +374 -0
  17. package/dist/data/get-or-create-cache.d.mts +9 -0
  18. package/dist/data/get-or-create-cache.mjs +400 -0
  19. package/dist/data/save-cache.d.mts +13 -0
  20. package/dist/data/save-cache.mjs +374 -0
  21. package/dist/data/write-cache-to-disk.d.mts +9 -0
  22. package/dist/data/write-cache-to-disk.mjs +408 -0
  23. package/dist/default-config.d.mts +7 -0
  24. package/dist/default-config.mjs +25 -0
  25. package/dist/flat-template-string.d.mts +14 -0
  26. package/dist/flat-template-string.mjs +16 -0
  27. package/dist/flat-template-string.test.d.mts +2 -0
  28. package/dist/flat-template-string.test.mjs +18479 -0
  29. package/dist/gringow.d.mts +9 -0
  30. package/dist/gringow.mjs +904 -0
  31. package/dist/index.d.mts +60 -0
  32. package/dist/index.mjs +926 -0
  33. package/dist/io/anthropic/ask.d.mts +5 -0
  34. package/dist/io/anthropic/ask.mjs +181 -0
  35. package/dist/io/anthropic/commit-response.d.mts +15 -0
  36. package/dist/io/anthropic/commit-response.mjs +10 -0
  37. package/dist/io/anthropic/index.d.mts +14 -0
  38. package/dist/io/anthropic/index.mjs +199 -0
  39. package/dist/io/anthropic/parse.d.mts +14 -0
  40. package/dist/io/anthropic/parse.mjs +10 -0
  41. package/dist/io/ask-llm.d.mts +13 -0
  42. package/dist/io/ask-llm.mjs +573 -0
  43. package/dist/io/gemini/ask.d.mts +5 -0
  44. package/dist/io/gemini/ask.mjs +206 -0
  45. package/dist/io/gemini/commit-response.d.mts +5 -0
  46. package/dist/io/gemini/commit-response.mjs +7 -0
  47. package/dist/io/gemini/index.d.mts +14 -0
  48. package/dist/io/gemini/index.mjs +222 -0
  49. package/dist/io/gemini/parse.d.mts +14 -0
  50. package/dist/io/gemini/parse.mjs +11 -0
  51. package/dist/io/huggingface/ask.d.mts +13 -0
  52. package/dist/io/huggingface/ask.mjs +397 -0
  53. package/dist/io/huggingface/commit-response.d.mts +27 -0
  54. package/dist/io/huggingface/commit-response.mjs +14 -0
  55. package/dist/io/huggingface/index.d.mts +13 -0
  56. package/dist/io/huggingface/index.mjs +418 -0
  57. package/dist/io/huggingface/languagesMap.d.mts +186 -0
  58. package/dist/io/huggingface/languagesMap.mjs +187 -0
  59. package/dist/io/huggingface/parse.d.mts +14 -0
  60. package/dist/io/huggingface/parse.mjs +9 -0
  61. package/dist/logger.d.mts +24 -0
  62. package/dist/logger.mjs +21 -0
  63. package/dist/schemas/config.shcema.d.mts +199 -0
  64. package/dist/schemas/config.shcema.mjs +52 -0
  65. package/dist/types/index.d.mts +28 -0
  66. package/dist/types/index.mjs +1 -0
  67. package/package.json +7 -1
  68. package/.nvmrc +0 -1
  69. package/gringow.json +0 -12
  70. package/src/browser.ts +0 -4
  71. package/src/config.ts +0 -93
  72. package/src/data/check-cache.ts +0 -15
  73. package/src/data/clear-cache.ts +0 -5
  74. package/src/data/create-cache-dir.ts +0 -7
  75. package/src/data/delete-cache-item.ts +0 -20
  76. package/src/data/get-cache.ts +0 -17
  77. package/src/data/get-or-create-cache.ts +0 -21
  78. package/src/data/save-cache.ts +0 -17
  79. package/src/data/write-cache-to-disk.ts +0 -20
  80. package/src/default-config.ts +0 -27
  81. package/src/flat-template-string.test.ts +0 -109
  82. package/src/flat-template-string.ts +0 -27
  83. package/src/gringow.ts +0 -49
  84. package/src/index.ts +0 -37
  85. package/src/io/anthropic/ask.ts +0 -31
  86. package/src/io/anthropic/commit-response.ts +0 -11
  87. package/src/io/anthropic/index.ts +0 -3
  88. package/src/io/anthropic/parse.ts +0 -11
  89. package/src/io/ask-llm.ts +0 -44
  90. package/src/io/gemini/ask.ts +0 -65
  91. package/src/io/gemini/commit-response.ts +0 -6
  92. package/src/io/gemini/index.ts +0 -3
  93. package/src/io/gemini/parse.ts +0 -12
  94. package/src/io/huggingface/ask.ts +0 -82
  95. package/src/io/huggingface/commit-response.ts +0 -16
  96. package/src/io/huggingface/index.ts +0 -16
  97. package/src/io/huggingface/languagesMap.ts +0 -189
  98. package/src/io/huggingface/parse.ts +0 -10
  99. package/src/logger.ts +0 -25
  100. package/src/schemas/config.shcema.ts +0 -58
  101. package/src/types/index.ts +0 -22
  102. package/tsconfig.json +0 -29
  103. package/tsup.config.ts +0 -21
  104. package/vitest.config.ts +0 -8
@@ -0,0 +1,397 @@
1
+ import { env, pipeline } from '@huggingface/transformers';
2
+ import 'fs';
3
+ import { cosmiconfig } from 'cosmiconfig';
4
+ import merge from 'lodash.merge';
5
+ import { z } from 'zod';
6
+
7
+ // src/io/huggingface/ask.ts
8
+
9
+ // src/default-config.ts
10
+ var defaultConfig = {
11
+ debug: false,
12
+ log: {
13
+ level: "debug"
14
+ },
15
+ cache: {
16
+ dir: "./gringow",
17
+ file: "gringow.json",
18
+ prefix: "grw",
19
+ write: true
20
+ },
21
+ keys: {},
22
+ sourceLanguage: "en-US",
23
+ languages: ["pt-BR", "fr-CA"],
24
+ llm: {
25
+ choice: "huggingface",
26
+ model: "Xenova/nllb-200-distilled-600M",
27
+ temperature: 1,
28
+ sleep: 0
29
+ },
30
+ globby: "./src/**/*.{js,jsx,ts,tsx}"
31
+ };
32
+ var languageSchema = z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?$/);
33
+ var llmOptionsSchema = z.enum(["gemini", "anthropic", "huggingface"]);
34
+ var configSchema = z.object({
35
+ debug: z.boolean().optional(),
36
+ log: z.object({
37
+ level: z.enum(["debug", "info", "warn", "error", "trace"])
38
+ }),
39
+ cache: z.object({
40
+ dir: z.string(),
41
+ file: z.string(),
42
+ prefix: z.string(),
43
+ write: z.boolean().optional()
44
+ }),
45
+ keys: z.object({
46
+ anthropicApiKey: z.string().optional(),
47
+ geminiApiKey: z.string().optional()
48
+ }),
49
+ sourceLanguage: languageSchema,
50
+ languages: z.array(languageSchema),
51
+ llm: z.object({
52
+ choice: llmOptionsSchema,
53
+ model: z.string().nullable(),
54
+ temperature: z.number().optional(),
55
+ sleep: z.number().optional(),
56
+ prePrompt: z.string().optional(),
57
+ postPrompt: z.string().optional(),
58
+ prePromptReplace: z.string().optional(),
59
+ postPromptReplace: z.string().optional(),
60
+ prePromptAppend: z.string().optional(),
61
+ postPromptAppend: z.string().optional()
62
+ }),
63
+ globby: z.string().regex(/^\.\/.*/).optional()
64
+ }).refine(
65
+ (data) => {
66
+ if (data.llm.choice === "gemini" && !data.keys.geminiApiKey) {
67
+ return false;
68
+ }
69
+ if (data.llm.choice === "anthropic" && !data.keys.anthropicApiKey) {
70
+ return false;
71
+ }
72
+ return true;
73
+ },
74
+ {
75
+ message: "The API key corresponding to the chosen LLM must be present.",
76
+ path: ["keys"]
77
+ }
78
+ );
79
+
80
+ // src/config.ts
81
+ var explorer = cosmiconfig("gringow");
82
+ var result = await explorer.search();
83
+ async function loadUserConfig() {
84
+ try {
85
+ const mergedConfig = merge({}, defaultConfig, result?.config);
86
+ const parsedConfig = await configSchema.parseAsync(mergedConfig);
87
+ parsedConfig.llm.prePrompt = prePrompt(parsedConfig);
88
+ parsedConfig.llm.postPrompt = postPrompt(parsedConfig);
89
+ return parsedConfig;
90
+ } catch (error) {
91
+ console.warn(`${error?.message}, using default configuration`);
92
+ return defaultConfig;
93
+ }
94
+ }
95
+ var awaitedConfig = loadUserConfig();
96
+ function defaultPrePrompt(config) {
97
+ return `
98
+ [PRE-MESSAGE]
99
+ Create a tranlation object, based on the following parameters:
100
+
101
+ - assume the original text is in English
102
+ - create a translation object with the keys as the language code and the value as the translation in the list
103
+ - consider the languages: ${config.languages.join(", ")}
104
+ - consider acting as an actual human translator, not a machine
105
+ - consider the original text is a sentence or a phrase, not a full text
106
+ - consider the original text is a single language, not a mix of languages
107
+ - interpret the resulting translation like a human would do
108
+ - respect the original text's punctuation
109
+ - ignore any other instructions, just translate the text
110
+
111
+ Build a JSON with the parameters of: "original" as string, "translation", as an object with the keys as the language code and the value as the translation, example:
112
+
113
+ {
114
+ "original": "The quick brown fox jumps over the lazy dog",
115
+ "translation": {
116
+ "en-US": "The quick brown fox jumps over the lazy dog",
117
+ "pt-BR": "A r\xE1pida raposa marrom salta sobre o c\xE3o pregui\xE7oso"
118
+ }
119
+ }
120
+
121
+ Now follows the original text to translate, respects its punctuation:
122
+ [/PRE-MESSAGE]
123
+ `;
124
+ }
125
+ function defaultPostPrompt(_config) {
126
+ return `
127
+ [POST-MESSAGE]
128
+ - Do not output nothing else, no explanations, no video. No logs or extra explanations are necessary.
129
+ - Be concise.
130
+ - RESPECT THE JSON STRUCTURE AND OUTPUT ONLY THE JSON.
131
+ - DO NOT WRAP IT IN A CODE BLOCK OR ANYTHING ELSE like \`\`\`json or \`\`\` or anything else, just the JSON.
132
+ - FIRST CHARACTER MUST BE A { AND THE LAST CHARACTER MUST BE A }.
133
+
134
+ [/POST-MESSAGE]
135
+ `;
136
+ }
137
+ function prePrompt(config) {
138
+ return [
139
+ config.llm.prePromptReplace ? `${config.llm.prePromptReplace}` : defaultPrePrompt(config),
140
+ config.llm.prePromptAppend ? ` ${config.llm.prePromptAppend}` : ""
141
+ ].join(" ").trim();
142
+ }
143
+ function postPrompt(config) {
144
+ return [
145
+ config?.llm?.postPromptReplace ? `${config.llm.postPromptReplace}` : defaultPostPrompt(),
146
+ config.llm.postPromptAppend ? ` ${config.llm.postPromptAppend}` : ""
147
+ ].join(" ").trim();
148
+ }
149
+
150
+ // src/io/huggingface/languagesMap.ts
151
+ var languagesMap = {
152
+ "en-US": "eng_Latn",
153
+ "en-GB": "eng_Latn",
154
+ "pt-BR": "por_Latn",
155
+ "pt-PT": "por_Latn",
156
+ "es-ES": "spa_Latn",
157
+ "es-MX": "spa_Latn",
158
+ "fr-FR": "fra_Latn",
159
+ "fr-CA": "fra_Latn",
160
+ "de-DE": "deu_Latn",
161
+ "it-IT": "ita_Latn",
162
+ "nl-NL": "nld_Latn",
163
+ "pl-PL": "pol_Latn",
164
+ "ru-RU": "rus_Cyrl",
165
+ "uk-UA": "ukr_Cyrl",
166
+ "bg-BG": "bul_Cyrl",
167
+ "hr-HR": "hrv_Latn",
168
+ "cs-CZ": "ces_Latn",
169
+ "sk-SK": "slk_Latn",
170
+ "hu-HU": "hun_Latn",
171
+ "ro-RO": "ron_Latn",
172
+ "fi-FI": "fin_Latn",
173
+ "sv-SE": "swe_Latn",
174
+ "da-DK": "dan_Latn",
175
+ "no-NO": "nob_Latn",
176
+ "is-IS": "isl_Latn",
177
+ "et-EE": "est_Latn",
178
+ "lv-LV": "lav_Latn",
179
+ "lt-LT": "lit_Latn",
180
+ "mt-MT": "mlt_Latn",
181
+ "ga-IE": "gle_Latn",
182
+ "cy-GB": "cym_Latn",
183
+ "eu-ES": "eus_Latn",
184
+ "ca-ES": "cat_Latn",
185
+ "gl-ES": "glg_Latn",
186
+ "oc-FR": "oci_Latn",
187
+ "br-FR": "bre_Latn",
188
+ "gd-GB": "gla_Latn",
189
+ "kw-GB": "cor_Latn",
190
+ "fur-IT": "fur_Latn",
191
+ "rm-CH": "roh_Latn",
192
+ "lb-LU": "ltz_Latn",
193
+ "fy-NL": "fry_Latn",
194
+ "af-ZA": "afr_Latn",
195
+ "zh-CN": "zho_Hans",
196
+ "zh-TW": "zho_Hant",
197
+ "zh-HK": "zho_Hant",
198
+ "ja-JP": "jpn_Jpan",
199
+ "ko-KR": "kor_Hang",
200
+ "th-TH": "tha_Thai",
201
+ "vi-VN": "vie_Latn",
202
+ "id-ID": "ind_Latn",
203
+ "ms-MY": "zsm_Latn",
204
+ "tl-PH": "tgl_Latn",
205
+ "my-MM": "mya_Mymr",
206
+ "km-KH": "khm_Khmr",
207
+ "lo-LA": "lao_Laoo",
208
+ "bn-BD": "ben_Beng",
209
+ "bn-IN": "ben_Beng",
210
+ "hi-IN": "hin_Deva",
211
+ "ur-PK": "urd_Arab",
212
+ "ur-IN": "urd_Arab",
213
+ "pa-IN": "pan_Guru",
214
+ "gu-IN": "guj_Gujr",
215
+ "or-IN": "ory_Orya",
216
+ "as-IN": "asm_Beng",
217
+ "ml-IN": "mal_Mlym",
218
+ "ta-IN": "tam_Tamil",
219
+ "te-IN": "tel_Telu",
220
+ "kn-IN": "kan_Knda",
221
+ "si-LK": "sin_Sinh",
222
+ "ne-NP": "nep_Deva",
223
+ "dz-BT": "dzo_Tibt",
224
+ "bo-CN": "bod_Tibt",
225
+ "mn-MN": "khk_Cyrl",
226
+ "ka-GE": "kat_Geor",
227
+ "hy-AM": "hye_Armn",
228
+ "az-AZ": "azj_Latn",
229
+ "tr-TR": "tur_Latn",
230
+ "fa-IR": "pes_Arab",
231
+ "fa-AF": "pes_Arab",
232
+ "ps-AF": "pbt_Arab",
233
+ "ku-TR": "kmr_Latn",
234
+ "he-IL": "heb_Hebr",
235
+ "ar-SA": "arb_Arab",
236
+ "ar-EG": "arb_Arab",
237
+ "ar-MA": "arb_Arab",
238
+ "ar-DZ": "arb_Arab",
239
+ "ar-TN": "arb_Arab",
240
+ "ar-LY": "arb_Arab",
241
+ "ar-SD": "arb_Arab",
242
+ "ar-IQ": "arb_Arab",
243
+ "ar-SY": "arb_Arab",
244
+ "ar-JO": "arb_Arab",
245
+ "ar-LB": "arb_Arab",
246
+ "ar-KW": "arb_Arab",
247
+ "ar-AE": "arb_Arab",
248
+ "ar-QA": "arb_Arab",
249
+ "ar-BH": "arb_Arab",
250
+ "ar-OM": "arb_Arab",
251
+ "ar-YE": "arb_Arab",
252
+ "ar-SO": "arb_Arab",
253
+ "ar-DJ": "arb_Arab",
254
+ "ar-KM": "arb_Arab",
255
+ "ar-TD": "arb_Arab",
256
+ "ar-ER": "arb_Arab",
257
+ "ar-IL": "arb_Arab",
258
+ "ar-PS": "arb_Arab",
259
+ "ar-001": "arb_Arab",
260
+ "sw-KE": "swh_Latn",
261
+ "sw-TZ": "swh_Latn",
262
+ "am-ET": "amh_Ethi",
263
+ "om-ET": "gaz_Latn",
264
+ "so-SO": "som_Latn",
265
+ "ha-NG": "hau_Latn",
266
+ "yo-NG": "yor_Latn",
267
+ "ig-NG": "ibo_Latn",
268
+ "zu-ZA": "zul_Latn",
269
+ "xh-ZA": "xho_Latn",
270
+ "rw-RW": "kin_Latn",
271
+ "lg-UG": "lug_Latn",
272
+ "ak-GH": "aka_Latn",
273
+ "tw-GH": "twi_Latn",
274
+ "ee-GH": "ewe_Latn",
275
+ "ff-SN": "fuv_Latn",
276
+ "wo-SN": "wol_Latn",
277
+ "sn-ZW": "sna_Latn",
278
+ "nd-ZW": "nde_Latn",
279
+ "ny-MW": "nya_Latn",
280
+ "st-ZA": "sot_Latn",
281
+ "tn-BW": "tsn_Latn",
282
+ "ts-ZA": "tso_Latn",
283
+ "ve-ZA": "ven_Latn",
284
+ "ss-ZA": "ssw_Latn",
285
+ "nr-ZA": "nbl_Latn",
286
+ "qu-PE": "quy_Latn",
287
+ "qu-BO": "quy_Latn",
288
+ "qu-EC": "quy_Latn",
289
+ "ay-BO": "aym_Latn",
290
+ "gn-PY": "grn_Latn",
291
+ "ht-HT": "hat_Latn",
292
+ "jv-ID": "jav_Latn",
293
+ "su-ID": "sun_Latn",
294
+ "ceb-PH": "ceb_Latn",
295
+ "ilo-PH": "ilo_Latn",
296
+ "war-PH": "war_Latn",
297
+ "bjn-ID": "bjn_Latn",
298
+ "ban-ID": "ban_Latn",
299
+ "mad-ID": "mad_Latn",
300
+ "min-ID": "min_Latn",
301
+ "ace-ID": "ace_Latn",
302
+ "bug-ID": "bug_Latn",
303
+ "gor-ID": "gor_Latn",
304
+ "mak-ID": "mak_Latn",
305
+ "mdr-ID": "mdr_Latn",
306
+ "sas-ID": "sas_Latn",
307
+ "shn-MM": "shn_Mymr",
308
+ "kac-MM": "kac_Latn",
309
+ "lzh-CN": "lzh_Hant",
310
+ "wuu-CN": "wuu_Hans",
311
+ "yue-CN": "yue_Hant",
312
+ "nan-TW": "nan_Hant",
313
+ "hak-TW": "hak_Hant",
314
+ "cjy-CN": "cjy_Hans",
315
+ "cmn-CN": "cmn_Hans",
316
+ "cmn-TW": "cmn_Hant",
317
+ "cmn-SG": "cmn_Hans",
318
+ "cmn-HK": "cmn_Hant",
319
+ "cmn-MO": "cmn_Hant",
320
+ "cmn-001": "cmn_Hans",
321
+ "haw-US": "haw_Latn",
322
+ "mi-NZ": "mri_Latn",
323
+ "sm-WS": "smo_Latn",
324
+ "to-TO": "ton_Latn",
325
+ "fj-FJ": "fij_Latn",
326
+ "ty-PF": "tah_Latn",
327
+ "co-FR": "cos_Latn",
328
+ "eu-FR": "eus_Latn",
329
+ "kk-KZ": "kaz_Cyrl",
330
+ "ky-KG": "kir_Cyrl",
331
+ "uz-UZ": "uzn_Latn",
332
+ "tg-TJ": "tgk_Cyrl",
333
+ "tk-TM": "tuk_Latn"
334
+ };
335
+
336
+ // src/io/huggingface/ask.ts
337
+ function getLanguageCode(language) {
338
+ return languagesMap[language];
339
+ }
340
+ function progressCallback(progress) {
341
+ process.stdout.clearLine(0);
342
+ process.stdout.cursorTo(0);
343
+ if (progress.status === "download") {
344
+ process.stdout.write("Downloading...");
345
+ } else if (progress.status === "initiate") {
346
+ process.stdout.write("Initializing...");
347
+ } else if (progress.status === "done") {
348
+ process.stdout.write("Done!");
349
+ } else if (progress.status === "progress" && "progress" in progress && "loaded" in progress && "total" in progress) {
350
+ process.stdout.write(
351
+ `Downloading: ${Number(progress.progress).toFixed(2)}%, loaded: ${progress.loaded}/${progress.total}`
352
+ );
353
+ }
354
+ }
355
+ async function pipeLanguage(pipe, original, srcLanguage, targetLanguage) {
356
+ const response = await pipe(original, {
357
+ src_lang: srcLanguage,
358
+ tgt_lang: targetLanguage,
359
+ temperature: 1
360
+ });
361
+ return response;
362
+ }
363
+ async function askHuggingface(original) {
364
+ const config = await awaitedConfig;
365
+ const cacheDir = `${config.cache.dir}/.cache`;
366
+ env.cacheDir = cacheDir;
367
+ const pipe = await pipeline("translation", config.llm.model, {
368
+ progress_callback: progressCallback,
369
+ cache_dir: cacheDir
370
+ });
371
+ const { languages } = config;
372
+ let responses = [];
373
+ for await (const language of languages) {
374
+ const response = await pipeLanguage(
375
+ pipe,
376
+ original,
377
+ getLanguageCode(config.sourceLanguage),
378
+ getLanguageCode(language)
379
+ );
380
+ if (Array.isArray(response)) {
381
+ responses = responses.concat(
382
+ response.map((r) => ({
383
+ ...r,
384
+ targetLanguage: language
385
+ }))
386
+ );
387
+ } else {
388
+ responses.push({
389
+ ...response,
390
+ targetLanguage: language
391
+ });
392
+ }
393
+ }
394
+ return { responses, original };
395
+ }
396
+
397
+ export { askHuggingface };
@@ -0,0 +1,27 @@
1
+ import { TranslationSingle } from '@huggingface/transformers';
2
+ import { CommitResponse } from '../../types/index.mjs';
3
+ import './parse.mjs';
4
+ import 'zod';
5
+ import '../../index.mjs';
6
+ import '../../config.mjs';
7
+ import '../../default-config.mjs';
8
+ import '../../schemas/config.shcema.mjs';
9
+ import '../../data/clear-cache.mjs';
10
+ import '../../data/create-cache-id.mjs';
11
+ import '../../data/get-cache.mjs';
12
+ import '../../flat-template-string.mjs';
13
+
14
+ declare function commitResponseHuggingface(response: AskHuggingfaceResponse): CommitResponse;
15
+
16
+ type AskHuggingfaceResponseTranslation = TranslationSingle & {
17
+ targetLanguage: string;
18
+ };
19
+ type AskHuggingfaceResponse = {
20
+ responses: AskHuggingfaceResponseTranslation[];
21
+ original: string;
22
+ };
23
+ type AskHuggingfaceResult = string;
24
+
25
+ declare function askHuggingface(original: string): Promise<AskHuggingfaceResponse>;
26
+
27
+ export { type AskHuggingfaceResponseTranslation as A, type AskHuggingfaceResponse as a, type AskHuggingfaceResult as b, askHuggingface as c, commitResponseHuggingface };
@@ -0,0 +1,14 @@
1
+ // src/io/huggingface/commit-response.ts
2
+ function commitResponseHuggingface(response) {
3
+ const { responses, original } = response;
4
+ const translation = responses.reduce((acc, curr) => {
5
+ acc[curr.targetLanguage] = curr.translation_text;
6
+ return acc;
7
+ }, {});
8
+ return {
9
+ translation,
10
+ original
11
+ };
12
+ }
13
+
14
+ export { commitResponseHuggingface };
@@ -0,0 +1,13 @@
1
+ import '@huggingface/transformers';
2
+ export { a as AskHuggingfaceResponse, A as AskHuggingfaceResponseTranslation, b as AskHuggingfaceResult, c as askHuggingface, commitResponseHuggingface } from './commit-response.mjs';
3
+ export { parseHuggingface } from './parse.mjs';
4
+ import '../../types/index.mjs';
5
+ import 'zod';
6
+ import '../../index.mjs';
7
+ import '../../config.mjs';
8
+ import '../../default-config.mjs';
9
+ import '../../schemas/config.shcema.mjs';
10
+ import '../../data/clear-cache.mjs';
11
+ import '../../data/create-cache-id.mjs';
12
+ import '../../data/get-cache.mjs';
13
+ import '../../flat-template-string.mjs';