@gringow/gringow 0.0.7 → 0.0.8
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 +23 -3
- package/dist/config.mjs +1 -1
- package/dist/config.test.d.mts +2 -0
- package/dist/config.test.mjs +18651 -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 +1 -1
- package/dist/gringow.d.mts +1 -1
- package/dist/gringow.mjs +42 -20
- package/dist/index.d.mts +25 -3
- package/dist/index.mjs +42 -20
- 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 +6 -6
- 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 +1 -1
- 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 +1 -1
- package/dist/io/huggingface/languagesMap.d.mts +5 -0
- 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 +18683 -0
- package/dist/schemas/config.shcema.d.mts +12 -12
- package/dist/types/index.d.mts +1 -1
- package/package.json +9 -10
|
@@ -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
|
@@ -18141,7 +18141,7 @@ describe("flatTemplateString", () => {
|
|
|
18141
18141
|
null,
|
|
18142
18142
|
void 0
|
|
18143
18143
|
]);
|
|
18144
|
-
globalExpect(result).toBe("Value:
|
|
18144
|
+
globalExpect(result).toBe("Value: , null: , undefined: ");
|
|
18145
18145
|
});
|
|
18146
18146
|
it("should convert numbers to string", () => {
|
|
18147
18147
|
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
|
|
|
@@ -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
|
|
|
@@ -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';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GringowCacheItem } from '../../index.mjs';
|
|
2
2
|
import { CommitResponse } from '../../types/index.mjs';
|
|
3
3
|
import '../../config.mjs';
|
|
4
|
-
import '../../default-config.mjs';
|
|
4
|
+
import '../../constants/default-config.mjs';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../../schemas/config.shcema.mjs';
|
|
7
7
|
import '../../data/clear-cache.mjs';
|
|
@@ -9,6 +9,12 @@ import '../../data/create-cache-id.mjs';
|
|
|
9
9
|
import '../../data/get-cache.mjs';
|
|
10
10
|
import '../../flat-template-string.mjs';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Parses the response from the Anthropic model.
|
|
14
|
+
*
|
|
15
|
+
* @param unparsed - The unparsed response from the model.
|
|
16
|
+
* @returns The parsed response.
|
|
17
|
+
*/
|
|
12
18
|
declare function parseAnthropic(unparsed: CommitResponse): GringowCacheItem;
|
|
13
19
|
|
|
14
20
|
export { parseAnthropic };
|
package/dist/io/ask-llm.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GringowCacheItem } 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 '../data/clear-cache.mjs';
|
|
@@ -8,6 +8,12 @@ import '../data/create-cache-id.mjs';
|
|
|
8
8
|
import '../data/get-cache.mjs';
|
|
9
9
|
import '../flat-template-string.mjs';
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Asks an LLM for a response.
|
|
13
|
+
*
|
|
14
|
+
* @param prompt - The prompt to ask the model.
|
|
15
|
+
* @returns The parsed response.
|
|
16
|
+
*/
|
|
11
17
|
declare function askLLM(prompt: string): Promise<GringowCacheItem>;
|
|
12
18
|
|
|
13
19
|
export { askLLM };
|
package/dist/io/ask-llm.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import 'fs';
|
|
|
8
8
|
|
|
9
9
|
// src/config.ts
|
|
10
10
|
|
|
11
|
-
// src/default-config.ts
|
|
11
|
+
// src/constants/default-config.ts
|
|
12
12
|
var defaultConfig = {
|
|
13
13
|
debug: false,
|
|
14
14
|
log: {
|
|
@@ -554,10 +554,10 @@ var llmChoices = {
|
|
|
554
554
|
parse: parseHuggingface
|
|
555
555
|
}
|
|
556
556
|
};
|
|
557
|
-
async function
|
|
558
|
-
const response = await
|
|
559
|
-
const unparsed =
|
|
560
|
-
const parsed =
|
|
557
|
+
async function processLLMChoice(llmChoice, prompt) {
|
|
558
|
+
const response = await llmChoice.ask(prompt);
|
|
559
|
+
const unparsed = llmChoice.commitResponse(response);
|
|
560
|
+
const parsed = llmChoice.parse(unparsed);
|
|
561
561
|
return parsed;
|
|
562
562
|
}
|
|
563
563
|
async function askLLM(prompt) {
|
|
@@ -567,7 +567,7 @@ async function askLLM(prompt) {
|
|
|
567
567
|
if (!llmChoice) {
|
|
568
568
|
throw new Error("LLMChoice not found");
|
|
569
569
|
}
|
|
570
|
-
return
|
|
570
|
+
return processLLMChoice(llmChoice, prompt);
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
export { askLLM };
|
package/dist/io/gemini/ask.d.mts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { GenerateContentResult } from '@google/generative-ai';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Asks the Gemini 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 askGemini(message: string): Promise<GenerateContentResult>;
|
|
4
10
|
|
|
5
11
|
export { askGemini };
|