@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
|
@@ -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: {
|
|
@@ -268,7 +268,7 @@ function parseGemini(unparsed) {
|
|
|
268
268
|
return parsed;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
// src/io/huggingface/
|
|
271
|
+
// src/io/huggingface/languages-map.ts
|
|
272
272
|
var languagesMap = {
|
|
273
273
|
"en-US": "eng_Latn",
|
|
274
274
|
"en-GB": "eng_Latn",
|
|
@@ -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 };
|
package/dist/io/gemini/ask.mjs
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { GenerateContentResult } from '@google/generative-ai';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Commits the response from the Gemini model.
|
|
5
|
+
*
|
|
6
|
+
* @param response - The response from the model.
|
|
7
|
+
* @returns The committed response.
|
|
8
|
+
*/
|
|
3
9
|
declare function commitResponseGemini(response: GenerateContentResult): string;
|
|
4
10
|
|
|
5
11
|
export { commitResponseGemini };
|
|
@@ -4,7 +4,7 @@ export { parseGemini } from './parse.mjs';
|
|
|
4
4
|
import '@google/generative-ai';
|
|
5
5
|
import '../../index.mjs';
|
|
6
6
|
import '../../config.mjs';
|
|
7
|
-
import '../../default-config.mjs';
|
|
7
|
+
import '../../constants/default-config.mjs';
|
|
8
8
|
import 'zod';
|
|
9
9
|
import '../../schemas/config.shcema.mjs';
|
|
10
10
|
import '../../data/clear-cache.mjs';
|
package/dist/io/gemini/index.mjs
CHANGED
|
@@ -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 Gemini model.
|
|
14
|
+
*
|
|
15
|
+
* @param unparsed - The unparsed response from the model.
|
|
16
|
+
* @returns The parsed response.
|
|
17
|
+
*/
|
|
12
18
|
declare function parseGemini(unparsed: CommitResponse): GringowCacheItem;
|
|
13
19
|
|
|
14
20
|
export { parseGemini };
|
|
@@ -4,7 +4,7 @@ import '../../types/index.mjs';
|
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../../index.mjs';
|
|
6
6
|
import '../../config.mjs';
|
|
7
|
-
import '../../default-config.mjs';
|
|
7
|
+
import '../../constants/default-config.mjs';
|
|
8
8
|
import '../../schemas/config.shcema.mjs';
|
|
9
9
|
import '../../data/clear-cache.mjs';
|
|
10
10
|
import '../../data/create-cache-id.mjs';
|
|
@@ -6,7 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
|
|
7
7
|
// src/io/huggingface/ask.ts
|
|
8
8
|
|
|
9
|
-
// src/default-config.ts
|
|
9
|
+
// src/constants/default-config.ts
|
|
10
10
|
var defaultConfig = {
|
|
11
11
|
debug: false,
|
|
12
12
|
log: {
|
|
@@ -147,7 +147,7 @@ function postPrompt(config) {
|
|
|
147
147
|
].join(" ").trim();
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
// src/io/huggingface/
|
|
150
|
+
// src/io/huggingface/languages-map.ts
|
|
151
151
|
var languagesMap = {
|
|
152
152
|
"en-US": "eng_Latn",
|
|
153
153
|
"en-GB": "eng_Latn",
|
|
@@ -4,13 +4,19 @@ import './parse.mjs';
|
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '../../index.mjs';
|
|
6
6
|
import '../../config.mjs';
|
|
7
|
-
import '../../default-config.mjs';
|
|
7
|
+
import '../../constants/default-config.mjs';
|
|
8
8
|
import '../../schemas/config.shcema.mjs';
|
|
9
9
|
import '../../data/clear-cache.mjs';
|
|
10
10
|
import '../../data/create-cache-id.mjs';
|
|
11
11
|
import '../../data/get-cache.mjs';
|
|
12
12
|
import '../../flat-template-string.mjs';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Commits the response from the Hugging Face model.
|
|
16
|
+
*
|
|
17
|
+
* @param response - The response from the model.
|
|
18
|
+
* @returns The committed response.
|
|
19
|
+
*/
|
|
14
20
|
declare function commitResponseHuggingface(response: AskHuggingfaceResponse): CommitResponse;
|
|
15
21
|
|
|
16
22
|
type AskHuggingfaceResponseTranslation = TranslationSingle & {
|
|
@@ -22,6 +28,12 @@ type AskHuggingfaceResponse = {
|
|
|
22
28
|
};
|
|
23
29
|
type AskHuggingfaceResult = string;
|
|
24
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Asks the Hugging Face model for a response.
|
|
33
|
+
*
|
|
34
|
+
* @param original - The original string.
|
|
35
|
+
* @returns The response from the pipeline.
|
|
36
|
+
*/
|
|
25
37
|
declare function askHuggingface(original: string): Promise<AskHuggingfaceResponse>;
|
|
26
38
|
|
|
27
39
|
export { type AskHuggingfaceResponseTranslation as A, type AskHuggingfaceResponse as a, type AskHuggingfaceResult as b, askHuggingface as c, commitResponseHuggingface };
|
|
@@ -5,7 +5,7 @@ import '../../types/index.mjs';
|
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '../../index.mjs';
|
|
7
7
|
import '../../config.mjs';
|
|
8
|
-
import '../../default-config.mjs';
|
|
8
|
+
import '../../constants/default-config.mjs';
|
|
9
9
|
import '../../schemas/config.shcema.mjs';
|
|
10
10
|
import '../../data/clear-cache.mjs';
|
|
11
11
|
import '../../data/create-cache-id.mjs';
|
|
@@ -6,7 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
|
|
7
7
|
// src/io/huggingface/ask.ts
|
|
8
8
|
|
|
9
|
-
// src/default-config.ts
|
|
9
|
+
// src/constants/default-config.ts
|
|
10
10
|
var defaultConfig = {
|
|
11
11
|
debug: false,
|
|
12
12
|
log: {
|
|
@@ -147,7 +147,7 @@ function postPrompt(config) {
|
|
|
147
147
|
].join(" ").trim();
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
// src/io/huggingface/
|
|
150
|
+
// src/io/huggingface/languages-map.ts
|
|
151
151
|
var languagesMap = {
|
|
152
152
|
"en-US": "eng_Latn",
|
|
153
153
|
"en-GB": "eng_Latn",
|
|
@@ -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 Hugging Face model.
|
|
14
|
+
*
|
|
15
|
+
* @param unparsed - The unparsed response from the model.
|
|
16
|
+
* @returns The parsed response.
|
|
17
|
+
*/
|
|
12
18
|
declare function parseHuggingface(unparsed: CommitResponse): GringowCacheItem;
|
|
13
19
|
|
|
14
20
|
export { parseHuggingface };
|
package/dist/logger.d.mts
CHANGED
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
declare const logger: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
9
|
-
};
|
|
10
|
-
info: {
|
|
11
|
-
(...data: any[]): void;
|
|
12
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
13
|
-
};
|
|
14
|
-
debug: {
|
|
15
|
-
(...data: any[]): void;
|
|
16
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
17
|
-
};
|
|
18
|
-
trace: {
|
|
19
|
-
(...data: any[]): void;
|
|
20
|
-
(message?: any, ...optionalParams: any[]): void;
|
|
21
|
-
};
|
|
2
|
+
debug(...params: unknown[]): void;
|
|
3
|
+
trace(...params: unknown[]): void;
|
|
4
|
+
info(...params: unknown[]): void;
|
|
5
|
+
warn(...params: unknown[]): void;
|
|
6
|
+
error(...params: unknown[]): void;
|
|
7
|
+
verbose(...params: unknown[]): void;
|
|
22
8
|
};
|
|
23
9
|
|
|
24
10
|
export { logger as default };
|
package/dist/logger.mjs
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
// src/logger.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
var Dim = "\x1B[2m";
|
|
3
|
+
var FgGreen = "\x1B[32m";
|
|
4
|
+
var FgYellow = "\x1B[33m";
|
|
5
|
+
var FgCyan = "\x1B[36m";
|
|
6
|
+
var FgWhite = "\x1B[37m";
|
|
7
|
+
var BgRed = "\x1B[41m";
|
|
8
|
+
var Clear = "\x1B[0m";
|
|
9
|
+
var Colors = {
|
|
10
|
+
debug: `${Dim}${FgGreen}`,
|
|
11
|
+
trace: `${Dim}${FgCyan}`,
|
|
12
|
+
info: `${FgCyan}`,
|
|
13
|
+
error: `${BgRed}${FgWhite}`,
|
|
14
|
+
warn: `${FgYellow}`,
|
|
15
|
+
verbose: `${FgWhite}`
|
|
8
16
|
};
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
var isProd = process.env.NODE_ENV === "production";
|
|
18
|
+
function log(level, ...params) {
|
|
19
|
+
console.log(`${!isProd ? Colors[level] : ""}${String(level).toUpperCase()} `, ...params, `${!isProd ? Clear : ""}`);
|
|
20
|
+
}
|
|
12
21
|
var logger = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
22
|
+
debug(...params) {
|
|
23
|
+
return log("debug", ...params);
|
|
24
|
+
},
|
|
25
|
+
trace(...params) {
|
|
26
|
+
return log("trace", ...params);
|
|
27
|
+
},
|
|
28
|
+
info(...params) {
|
|
29
|
+
return log("info", ...params);
|
|
30
|
+
},
|
|
31
|
+
warn(...params) {
|
|
32
|
+
return log("warn", ...params);
|
|
33
|
+
},
|
|
34
|
+
error(...params) {
|
|
35
|
+
return log("error", ...params);
|
|
36
|
+
},
|
|
37
|
+
verbose(...params) {
|
|
38
|
+
return log("verbose", ...params);
|
|
39
|
+
}
|
|
18
40
|
};
|
|
19
41
|
var logger_default = logger;
|
|
20
42
|
|