@gringow/gringow 0.0.7 → 0.0.9
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/dist/config.d.mts +21 -1
- package/dist/config.mjs +1 -1
- package/dist/config.test.d.mts +2 -0
- package/dist/config.test.mjs +18666 -0
- package/dist/{default-config.d.mts → constants/default-config.d.mts} +1 -1
- package/dist/{default-config.mjs → constants/default-config.mjs} +1 -1
- package/dist/data/check-cache.d.mts +1 -1
- package/dist/data/check-cache.mjs +37 -15
- package/dist/data/clear-cache.d.mts +9 -0
- package/dist/data/clear-cache.mjs +1 -1
- package/dist/data/create-cache-dir.mjs +1 -1
- package/dist/data/delete-cache-item.d.mts +1 -1
- package/dist/data/delete-cache-item.mjs +1 -1
- package/dist/data/get-cache.d.mts +10 -0
- package/dist/data/get-cache.mjs +1 -1
- package/dist/data/get-or-create-cache.d.mts +1 -1
- package/dist/data/get-or-create-cache.mjs +1 -1
- package/dist/data/save-cache.d.mts +7 -1
- package/dist/data/save-cache.mjs +1 -1
- package/dist/data/write-cache-to-disk.d.mts +1 -1
- package/dist/data/write-cache-to-disk.mjs +1 -1
- package/dist/flat-template-string.test.mjs +22 -7
- package/dist/gringow.d.mts +1 -1
- package/dist/gringow.mjs +43 -21
- package/dist/index.d.mts +25 -3
- package/dist/index.mjs +43 -21
- package/dist/io/anthropic/ask.d.mts +6 -0
- package/dist/io/anthropic/ask.mjs +1 -1
- package/dist/io/anthropic/commit-response.d.mts +7 -1
- package/dist/io/anthropic/index.d.mts +1 -1
- package/dist/io/anthropic/index.mjs +1 -1
- package/dist/io/anthropic/parse.d.mts +7 -1
- package/dist/io/ask-llm.d.mts +7 -1
- package/dist/io/ask-llm.mjs +7 -7
- package/dist/io/gemini/ask.d.mts +6 -0
- package/dist/io/gemini/ask.mjs +1 -1
- package/dist/io/gemini/commit-response.d.mts +6 -0
- package/dist/io/gemini/index.d.mts +1 -1
- package/dist/io/gemini/index.mjs +1 -1
- package/dist/io/gemini/parse.d.mts +7 -1
- package/dist/io/huggingface/ask.d.mts +1 -1
- package/dist/io/huggingface/ask.mjs +2 -2
- package/dist/io/huggingface/commit-response.d.mts +13 -1
- package/dist/io/huggingface/index.d.mts +1 -1
- package/dist/io/huggingface/index.mjs +2 -2
- package/dist/io/huggingface/{languagesMap.d.mts → languages-map.d.mts} +5 -0
- package/dist/io/huggingface/{languagesMap.mjs → languages-map.mjs} +1 -1
- package/dist/io/huggingface/parse.d.mts +7 -1
- package/dist/logger.d.mts +6 -20
- package/dist/logger.mjs +36 -14
- package/dist/logger.test.d.mts +2 -0
- package/dist/logger.test.mjs +18698 -0
- package/dist/types/index.d.mts +1 -1
- package/package.json +14 -12
|
@@ -7,7 +7,7 @@ import { mkdir, stat, statSync, mkdirSync } from 'fs';
|
|
|
7
7
|
|
|
8
8
|
// src/data/get-cache.ts
|
|
9
9
|
|
|
10
|
-
// src/default-config.ts
|
|
10
|
+
// src/constants/default-config.ts
|
|
11
11
|
var defaultConfig = {
|
|
12
12
|
debug: false,
|
|
13
13
|
log: {
|
|
@@ -398,22 +398,44 @@ async function getOrCreateCache() {
|
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
// src/logger.ts
|
|
401
|
-
var
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
401
|
+
var Dim = "\x1B[2m";
|
|
402
|
+
var FgGreen = "\x1B[32m";
|
|
403
|
+
var FgYellow = "\x1B[33m";
|
|
404
|
+
var FgCyan = "\x1B[36m";
|
|
405
|
+
var FgWhite = "\x1B[37m";
|
|
406
|
+
var BgRed = "\x1B[41m";
|
|
407
|
+
var Clear = "\x1B[0m";
|
|
408
|
+
var Colors = {
|
|
409
|
+
debug: `${Dim}${FgGreen}`,
|
|
410
|
+
trace: `${Dim}${FgCyan}`,
|
|
411
|
+
info: `${FgCyan}`,
|
|
412
|
+
error: `${BgRed}${FgWhite}`,
|
|
413
|
+
warn: `${FgYellow}`,
|
|
414
|
+
verbose: `${FgWhite}`
|
|
407
415
|
};
|
|
408
|
-
var
|
|
409
|
-
|
|
410
|
-
|
|
416
|
+
var isProd = process.env.NODE_ENV === "production";
|
|
417
|
+
function log(level, ...params) {
|
|
418
|
+
console.log(`${!isProd ? Colors[level] : ""}${String(level).toUpperCase()} `, ...params, `${!isProd ? Clear : ""}`);
|
|
419
|
+
}
|
|
411
420
|
var logger = {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
421
|
+
debug(...params) {
|
|
422
|
+
return log("debug", ...params);
|
|
423
|
+
},
|
|
424
|
+
trace(...params) {
|
|
425
|
+
return log("trace", ...params);
|
|
426
|
+
},
|
|
427
|
+
info(...params) {
|
|
428
|
+
return log("info", ...params);
|
|
429
|
+
},
|
|
430
|
+
warn(...params) {
|
|
431
|
+
return log("warn", ...params);
|
|
432
|
+
},
|
|
433
|
+
error(...params) {
|
|
434
|
+
return log("error", ...params);
|
|
435
|
+
},
|
|
436
|
+
verbose(...params) {
|
|
437
|
+
return log("verbose", ...params);
|
|
438
|
+
}
|
|
417
439
|
};
|
|
418
440
|
var logger_default = logger;
|
|
419
441
|
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clears all translation cache by saving an empty object
|
|
3
|
+
*
|
|
4
|
+
* @returns Promise that resolves when cache is cleared
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* await clearCache()
|
|
8
|
+
* // Cache is now empty
|
|
9
|
+
*/
|
|
1
10
|
declare function clearCache(): Promise<void>;
|
|
2
11
|
|
|
3
12
|
export { clearCache };
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the raw cache content from the filesystem
|
|
3
|
+
*
|
|
4
|
+
* @returns Promise that resolves to the raw cache content as a string
|
|
5
|
+
* @throws {GringowError} If there is an error reading the cache file
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const rawCache = await getCache()
|
|
9
|
+
* const cache = JSON.parse(rawCache)
|
|
10
|
+
*/
|
|
1
11
|
declare function getCache(): Promise<string>;
|
|
2
12
|
|
|
3
13
|
export { getCache };
|
package/dist/data/get-cache.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GringowCache } from '../index.mjs';
|
|
2
2
|
import '../config.mjs';
|
|
3
|
-
import '../default-config.mjs';
|
|
3
|
+
import '../constants/default-config.mjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../schemas/config.shcema.mjs';
|
|
6
6
|
import './clear-cache.mjs';
|
|
@@ -8,6 +8,12 @@ import './create-cache-id.mjs';
|
|
|
8
8
|
import './get-cache.mjs';
|
|
9
9
|
import '../flat-template-string.mjs';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Saves the cache to disk.
|
|
13
|
+
*
|
|
14
|
+
* @param cache - The cache to save.
|
|
15
|
+
* @returns The cache.
|
|
16
|
+
*/
|
|
11
17
|
declare function saveCache(cache: GringowCache): Promise<void>;
|
|
12
18
|
|
|
13
19
|
export { saveCache };
|
package/dist/data/save-cache.mjs
CHANGED
|
@@ -39,7 +39,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
39
39
|
mod
|
|
40
40
|
));
|
|
41
41
|
|
|
42
|
-
// ../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.
|
|
42
|
+
// ../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
43
43
|
function encodeInteger(builder, num, relative2) {
|
|
44
44
|
let delta = num - relative2;
|
|
45
45
|
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
@@ -78,7 +78,7 @@ function encode(decoded) {
|
|
|
78
78
|
}
|
|
79
79
|
var comma2, semicolon, chars2, intToChar2, charToInt2, bufLength, td, StringWriter;
|
|
80
80
|
var init_sourcemap_codec = __esm({
|
|
81
|
-
"../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.
|
|
81
|
+
"../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs"() {
|
|
82
82
|
comma2 = ",".charCodeAt(0);
|
|
83
83
|
semicolon = ";".charCodeAt(0);
|
|
84
84
|
chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -126,7 +126,7 @@ var init_sourcemap_codec = __esm({
|
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
// ../node_modules/.pnpm/magic-string@0.30.
|
|
129
|
+
// ../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs
|
|
130
130
|
var magic_string_es_exports = {};
|
|
131
131
|
__export(magic_string_es_exports, {
|
|
132
132
|
Bundle: () => Bundle,
|
|
@@ -202,7 +202,7 @@ function getLocator(source) {
|
|
|
202
202
|
}
|
|
203
203
|
var BitSet, Chunk, btoa, SourceMap, toString4, wordRegex, Mappings, n, warned, MagicString, hasOwnProp, Bundle;
|
|
204
204
|
var init_magic_string_es = __esm({
|
|
205
|
-
"../node_modules/.pnpm/magic-string@0.30.
|
|
205
|
+
"../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs"() {
|
|
206
206
|
init_sourcemap_codec();
|
|
207
207
|
BitSet = class _BitSet {
|
|
208
208
|
constructor(arg) {
|
|
@@ -573,6 +573,9 @@ var init_magic_string_es = __esm({
|
|
|
573
573
|
}
|
|
574
574
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
575
575
|
});
|
|
576
|
+
if (this.outro) {
|
|
577
|
+
mappings.advance(this.outro);
|
|
578
|
+
}
|
|
576
579
|
return {
|
|
577
580
|
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
578
581
|
sources: [
|
|
@@ -930,10 +933,13 @@ var init_magic_string_es = __esm({
|
|
|
930
933
|
_split(index) {
|
|
931
934
|
if (this.byStart[index] || this.byEnd[index]) return;
|
|
932
935
|
let chunk = this.lastSearchedChunk;
|
|
936
|
+
let previousChunk = chunk;
|
|
933
937
|
const searchForward = index > chunk.end;
|
|
934
938
|
while (chunk) {
|
|
935
939
|
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
936
940
|
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
941
|
+
if (chunk === previousChunk) return;
|
|
942
|
+
previousChunk = chunk;
|
|
937
943
|
}
|
|
938
944
|
}
|
|
939
945
|
_splitChunk(chunk, index) {
|
|
@@ -1080,7 +1086,12 @@ var init_magic_string_es = __esm({
|
|
|
1080
1086
|
const { original } = this;
|
|
1081
1087
|
const index = original.indexOf(string2);
|
|
1082
1088
|
if (index !== -1) {
|
|
1083
|
-
|
|
1089
|
+
if (typeof replacement === "function") {
|
|
1090
|
+
replacement = replacement(string2, index, original);
|
|
1091
|
+
}
|
|
1092
|
+
if (string2 !== replacement) {
|
|
1093
|
+
this.overwrite(index, index + string2.length, replacement);
|
|
1094
|
+
}
|
|
1084
1095
|
}
|
|
1085
1096
|
return this;
|
|
1086
1097
|
}
|
|
@@ -1095,7 +1106,11 @@ var init_magic_string_es = __esm({
|
|
|
1095
1106
|
const stringLength = string2.length;
|
|
1096
1107
|
for (let index = original.indexOf(string2); index !== -1; index = original.indexOf(string2, index + stringLength)) {
|
|
1097
1108
|
const previous = original.slice(index, index + stringLength);
|
|
1098
|
-
|
|
1109
|
+
let _replacement = replacement;
|
|
1110
|
+
if (typeof replacement === "function") {
|
|
1111
|
+
_replacement = replacement(previous, index, original);
|
|
1112
|
+
}
|
|
1113
|
+
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1099
1114
|
}
|
|
1100
1115
|
return this;
|
|
1101
1116
|
}
|
|
@@ -18141,7 +18156,7 @@ describe("flatTemplateString", () => {
|
|
|
18141
18156
|
null,
|
|
18142
18157
|
void 0
|
|
18143
18158
|
]);
|
|
18144
|
-
globalExpect(result).toBe("Value:
|
|
18159
|
+
globalExpect(result).toBe("Value: , null: , undefined: ");
|
|
18145
18160
|
});
|
|
18146
18161
|
it("should convert numbers to string", () => {
|
|
18147
18162
|
const result = flatTemplateString(createTemplateStringsArray(["Number: ", ""]), [42]);
|
package/dist/gringow.d.mts
CHANGED
package/dist/gringow.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { env, pipeline } from '@huggingface/transformers';
|
|
|
11
11
|
|
|
12
12
|
// src/config.ts
|
|
13
13
|
|
|
14
|
-
// src/default-config.ts
|
|
14
|
+
// src/constants/default-config.ts
|
|
15
15
|
var defaultConfig = {
|
|
16
16
|
debug: false,
|
|
17
17
|
log: {
|
|
@@ -402,22 +402,44 @@ async function getOrCreateCache() {
|
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
// src/logger.ts
|
|
405
|
-
var
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
405
|
+
var Dim = "\x1B[2m";
|
|
406
|
+
var FgGreen = "\x1B[32m";
|
|
407
|
+
var FgYellow = "\x1B[33m";
|
|
408
|
+
var FgCyan = "\x1B[36m";
|
|
409
|
+
var FgWhite = "\x1B[37m";
|
|
410
|
+
var BgRed = "\x1B[41m";
|
|
411
|
+
var Clear = "\x1B[0m";
|
|
412
|
+
var Colors = {
|
|
413
|
+
debug: `${Dim}${FgGreen}`,
|
|
414
|
+
trace: `${Dim}${FgCyan}`,
|
|
415
|
+
info: `${FgCyan}`,
|
|
416
|
+
error: `${BgRed}${FgWhite}`,
|
|
417
|
+
warn: `${FgYellow}`,
|
|
418
|
+
verbose: `${FgWhite}`
|
|
411
419
|
};
|
|
412
|
-
var
|
|
413
|
-
|
|
414
|
-
|
|
420
|
+
var isProd = process.env.NODE_ENV === "production";
|
|
421
|
+
function log(level, ...params) {
|
|
422
|
+
console.log(`${!isProd ? Colors[level] : ""}${String(level).toUpperCase()} `, ...params, `${!isProd ? Clear : ""}`);
|
|
423
|
+
}
|
|
415
424
|
var logger = {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
425
|
+
debug(...params) {
|
|
426
|
+
return log("debug", ...params);
|
|
427
|
+
},
|
|
428
|
+
trace(...params) {
|
|
429
|
+
return log("trace", ...params);
|
|
430
|
+
},
|
|
431
|
+
info(...params) {
|
|
432
|
+
return log("info", ...params);
|
|
433
|
+
},
|
|
434
|
+
warn(...params) {
|
|
435
|
+
return log("warn", ...params);
|
|
436
|
+
},
|
|
437
|
+
error(...params) {
|
|
438
|
+
return log("error", ...params);
|
|
439
|
+
},
|
|
440
|
+
verbose(...params) {
|
|
441
|
+
return log("verbose", ...params);
|
|
442
|
+
}
|
|
421
443
|
};
|
|
422
444
|
var logger_default = logger;
|
|
423
445
|
|
|
@@ -578,7 +600,7 @@ function parseGemini(unparsed) {
|
|
|
578
600
|
return parsed;
|
|
579
601
|
}
|
|
580
602
|
|
|
581
|
-
// src/io/huggingface/
|
|
603
|
+
// src/io/huggingface/languages-map.ts
|
|
582
604
|
var languagesMap = {
|
|
583
605
|
"en-US": "eng_Latn",
|
|
584
606
|
"en-GB": "eng_Latn",
|
|
@@ -864,10 +886,10 @@ var llmChoices = {
|
|
|
864
886
|
parse: parseHuggingface
|
|
865
887
|
}
|
|
866
888
|
};
|
|
867
|
-
async function
|
|
868
|
-
const response = await
|
|
869
|
-
const unparsed =
|
|
870
|
-
const parsed =
|
|
889
|
+
async function processLLMChoice(llmChoice, prompt) {
|
|
890
|
+
const response = await llmChoice.ask(prompt);
|
|
891
|
+
const unparsed = llmChoice.commitResponse(response);
|
|
892
|
+
const parsed = llmChoice.parse(unparsed);
|
|
871
893
|
return parsed;
|
|
872
894
|
}
|
|
873
895
|
async function askLLM(prompt) {
|
|
@@ -877,7 +899,7 @@ async function askLLM(prompt) {
|
|
|
877
899
|
if (!llmChoice) {
|
|
878
900
|
throw new Error("LLMChoice not found");
|
|
879
901
|
}
|
|
880
|
-
return
|
|
902
|
+
return processLLMChoice(llmChoice, prompt);
|
|
881
903
|
}
|
|
882
904
|
|
|
883
905
|
// src/gringow.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -3,10 +3,22 @@ export { clearCache } from './data/clear-cache.mjs';
|
|
|
3
3
|
export { createCacheId } from './data/create-cache-id.mjs';
|
|
4
4
|
export { getCache } from './data/get-cache.mjs';
|
|
5
5
|
export { flatTemplateString } from './flat-template-string.mjs';
|
|
6
|
-
export { GringowConfig } from './default-config.mjs';
|
|
6
|
+
export { GringowConfig } from './constants/default-config.mjs';
|
|
7
7
|
import 'zod';
|
|
8
8
|
import './schemas/config.shcema.mjs';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a cache item exists for the given ID
|
|
12
|
+
*
|
|
13
|
+
* @param cacheId - The cache ID to check
|
|
14
|
+
* @returns Promise that resolves to the cached item if found, or undefined otherwise
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const item = await checkCache("gid_123abc")
|
|
18
|
+
* if (item) {
|
|
19
|
+
* console.log("Found in cache:", item.translation)
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
10
22
|
declare function checkCache(cacheId: string): Promise<GringowCacheItem | undefined>;
|
|
11
23
|
|
|
12
24
|
/**
|
|
@@ -17,14 +29,24 @@ declare function checkCache(cacheId: string): Promise<GringowCacheItem | undefin
|
|
|
17
29
|
*/
|
|
18
30
|
declare function deleteCacheItem(cacheId: string): Promise<GringowCache>;
|
|
19
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Gets the existing cache or creates a new empty one if it doesn't exist
|
|
34
|
+
*
|
|
35
|
+
* @returns Promise that resolves to the cache object
|
|
36
|
+
* @throws {GringowError} If there is an error reading/writing the cache file
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const cache = await getOrCreateCache()
|
|
40
|
+
* // Returns existing cache or creates new empty cache: {}
|
|
41
|
+
*/
|
|
20
42
|
declare function getOrCreateCache(): Promise<GringowCache>;
|
|
21
43
|
|
|
22
44
|
/**
|
|
23
45
|
* Writes the cache to disk.
|
|
24
46
|
*
|
|
25
47
|
* @param cacheId - The cache ID.
|
|
26
|
-
* @param cached - The cached
|
|
27
|
-
* @returns The
|
|
48
|
+
* @param cached - The cached item.
|
|
49
|
+
* @returns The cached item.
|
|
28
50
|
*/
|
|
29
51
|
declare function writeCacheToDisk(cacheId: string, cached: GringowCacheItem): Promise<GringowCacheItem>;
|
|
30
52
|
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { env, pipeline } from '@huggingface/transformers';
|
|
|
11
11
|
|
|
12
12
|
// src/config.ts
|
|
13
13
|
|
|
14
|
-
// src/default-config.ts
|
|
14
|
+
// src/constants/default-config.ts
|
|
15
15
|
var defaultConfig = {
|
|
16
16
|
debug: false,
|
|
17
17
|
log: {
|
|
@@ -408,22 +408,44 @@ async function getOrCreateCache() {
|
|
|
408
408
|
}
|
|
409
409
|
|
|
410
410
|
// src/logger.ts
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
411
|
+
var Dim = "\x1B[2m";
|
|
412
|
+
var FgGreen = "\x1B[32m";
|
|
413
|
+
var FgYellow = "\x1B[33m";
|
|
414
|
+
var FgCyan = "\x1B[36m";
|
|
415
|
+
var FgWhite = "\x1B[37m";
|
|
416
|
+
var BgRed = "\x1B[41m";
|
|
417
|
+
var Clear = "\x1B[0m";
|
|
418
|
+
var Colors = {
|
|
419
|
+
debug: `${Dim}${FgGreen}`,
|
|
420
|
+
trace: `${Dim}${FgCyan}`,
|
|
421
|
+
info: `${FgCyan}`,
|
|
422
|
+
error: `${BgRed}${FgWhite}`,
|
|
423
|
+
warn: `${FgYellow}`,
|
|
424
|
+
verbose: `${FgWhite}`
|
|
417
425
|
};
|
|
418
|
-
var
|
|
419
|
-
|
|
420
|
-
|
|
426
|
+
var isProd = process.env.NODE_ENV === "production";
|
|
427
|
+
function log(level, ...params) {
|
|
428
|
+
console.log(`${!isProd ? Colors[level] : ""}${String(level).toUpperCase()} `, ...params, `${!isProd ? Clear : ""}`);
|
|
429
|
+
}
|
|
421
430
|
var logger = {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
431
|
+
debug(...params) {
|
|
432
|
+
return log("debug", ...params);
|
|
433
|
+
},
|
|
434
|
+
trace(...params) {
|
|
435
|
+
return log("trace", ...params);
|
|
436
|
+
},
|
|
437
|
+
info(...params) {
|
|
438
|
+
return log("info", ...params);
|
|
439
|
+
},
|
|
440
|
+
warn(...params) {
|
|
441
|
+
return log("warn", ...params);
|
|
442
|
+
},
|
|
443
|
+
error(...params) {
|
|
444
|
+
return log("error", ...params);
|
|
445
|
+
},
|
|
446
|
+
verbose(...params) {
|
|
447
|
+
return log("verbose", ...params);
|
|
448
|
+
}
|
|
427
449
|
};
|
|
428
450
|
var logger_default = logger;
|
|
429
451
|
|
|
@@ -600,7 +622,7 @@ function parseGemini(unparsed) {
|
|
|
600
622
|
return parsed;
|
|
601
623
|
}
|
|
602
624
|
|
|
603
|
-
// src/io/huggingface/
|
|
625
|
+
// src/io/huggingface/languages-map.ts
|
|
604
626
|
var languagesMap = {
|
|
605
627
|
"en-US": "eng_Latn",
|
|
606
628
|
"en-GB": "eng_Latn",
|
|
@@ -886,10 +908,10 @@ var llmChoices = {
|
|
|
886
908
|
parse: parseHuggingface
|
|
887
909
|
}
|
|
888
910
|
};
|
|
889
|
-
async function
|
|
890
|
-
const response = await
|
|
891
|
-
const unparsed =
|
|
892
|
-
const parsed =
|
|
911
|
+
async function processLLMChoice(llmChoice, prompt) {
|
|
912
|
+
const response = await llmChoice.ask(prompt);
|
|
913
|
+
const unparsed = llmChoice.commitResponse(response);
|
|
914
|
+
const parsed = llmChoice.parse(unparsed);
|
|
893
915
|
return parsed;
|
|
894
916
|
}
|
|
895
917
|
async function askLLM(prompt) {
|
|
@@ -899,7 +921,7 @@ async function askLLM(prompt) {
|
|
|
899
921
|
if (!llmChoice) {
|
|
900
922
|
throw new Error("LLMChoice not found");
|
|
901
923
|
}
|
|
902
|
-
return
|
|
924
|
+
return processLLMChoice(llmChoice, prompt);
|
|
903
925
|
}
|
|
904
926
|
|
|
905
927
|
// src/gringow.ts
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import Anthropic from '@anthropic-ai/sdk';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Asks the Anthropic model for a response.
|
|
5
|
+
*
|
|
6
|
+
* @param message - The message to ask the model.
|
|
7
|
+
* @returns The response from the model.
|
|
8
|
+
*/
|
|
3
9
|
declare function askAnthropic(message: string): Promise<Anthropic.Messages.Message>;
|
|
4
10
|
|
|
5
11
|
export { askAnthropic };
|
|
@@ -3,13 +3,19 @@ import { CommitResponse } from '../../types/index.mjs';
|
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '../../index.mjs';
|
|
5
5
|
import '../../config.mjs';
|
|
6
|
-
import '../../default-config.mjs';
|
|
6
|
+
import '../../constants/default-config.mjs';
|
|
7
7
|
import '../../schemas/config.shcema.mjs';
|
|
8
8
|
import '../../data/clear-cache.mjs';
|
|
9
9
|
import '../../data/create-cache-id.mjs';
|
|
10
10
|
import '../../data/get-cache.mjs';
|
|
11
11
|
import '../../flat-template-string.mjs';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Commits the response from the Anthropic model.
|
|
15
|
+
*
|
|
16
|
+
* @param response - The response from the model.
|
|
17
|
+
* @returns The committed response.
|
|
18
|
+
*/
|
|
13
19
|
declare function commitResponseAnthropic(response: Anthropic.Messages.Message): CommitResponse;
|
|
14
20
|
|
|
15
21
|
export { commitResponseAnthropic };
|
|
@@ -6,7 +6,7 @@ import '../../types/index.mjs';
|
|
|
6
6
|
import 'zod';
|
|
7
7
|
import '../../index.mjs';
|
|
8
8
|
import '../../config.mjs';
|
|
9
|
-
import '../../default-config.mjs';
|
|
9
|
+
import '../../constants/default-config.mjs';
|
|
10
10
|
import '../../schemas/config.shcema.mjs';
|
|
11
11
|
import '../../data/clear-cache.mjs';
|
|
12
12
|
import '../../data/create-cache-id.mjs';
|