@gringow/gringow 0.0.8 → 0.1.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.
- package/dist/config.d.mts +5 -5
- package/dist/config.mjs +19 -11
- package/dist/config.test.mjs +62 -53
- package/dist/data/check-cache.mjs +19 -11
- package/dist/data/clear-cache.mjs +19 -11
- package/dist/data/create-cache-dir.mjs +19 -11
- package/dist/data/delete-cache-item.mjs +19 -11
- package/dist/data/get-cache.mjs +19 -11
- package/dist/data/get-or-create-cache.mjs +19 -11
- package/dist/data/save-cache.mjs +19 -11
- package/dist/data/write-cache-to-disk.mjs +19 -11
- package/dist/flat-template-string.test.mjs +21 -6
- package/dist/gringow.d.mts +1 -1
- package/dist/gringow.mjs +81 -40
- package/dist/index.d.mts +5 -1
- package/dist/index.mjs +81 -40
- package/dist/io/anthropic/ask.d.mts +2 -2
- package/dist/io/anthropic/ask.mjs +28 -19
- package/dist/io/anthropic/index.mjs +28 -19
- package/dist/io/ask-llm.d.mts +1 -1
- package/dist/io/ask-llm.mjs +44 -35
- package/dist/io/gemini/ask.d.mts +2 -2
- package/dist/io/gemini/ask.mjs +30 -22
- package/dist/io/gemini/index.mjs +30 -22
- package/dist/io/huggingface/ask.mjs +20 -12
- package/dist/io/huggingface/index.mjs +20 -12
- package/dist/io/huggingface/{languagesMap.mjs → languages-map.mjs} +1 -1
- package/dist/logger.test.mjs +21 -6
- package/dist/schemas/config.shcema.d.mts +19 -19
- package/dist/schemas/config.shcema.mjs +3 -3
- package/dist/types/index.d.mts +1 -1
- package/package.json +7 -4
- /package/dist/io/huggingface/{languagesMap.d.mts → languages-map.d.mts} +0 -0
package/dist/config.d.mts
CHANGED
|
@@ -44,21 +44,21 @@ declare const awaitedConfig: Promise<{
|
|
|
44
44
|
llm: {
|
|
45
45
|
choice: "gemini" | "anthropic" | "huggingface";
|
|
46
46
|
model: string | null;
|
|
47
|
-
prePrompt?: string | undefined;
|
|
48
|
-
postPrompt?: string | undefined;
|
|
49
47
|
temperature?: number | undefined;
|
|
50
48
|
sleep?: number | undefined;
|
|
49
|
+
prePrompt?: string | undefined;
|
|
50
|
+
postPrompt?: string | undefined;
|
|
51
51
|
prePromptReplace?: string | undefined;
|
|
52
52
|
postPromptReplace?: string | undefined;
|
|
53
53
|
prePromptAppend?: string | undefined;
|
|
54
|
-
|
|
54
|
+
postPromptPrepend?: string | undefined;
|
|
55
55
|
};
|
|
56
56
|
debug?: boolean | undefined;
|
|
57
57
|
globby?: string | undefined;
|
|
58
58
|
}>;
|
|
59
59
|
declare function defaultPrePrompt(config: GringowConfig): string;
|
|
60
60
|
declare function defaultPostPrompt(_config: GringowConfig): string;
|
|
61
|
-
declare function prePrompt(config: GringowConfig): string;
|
|
62
|
-
declare function postPrompt(config: GringowConfig): string;
|
|
61
|
+
declare function prePrompt(config: GringowConfig, append?: string, replace?: string): string;
|
|
62
|
+
declare function postPrompt(config: GringowConfig, prepend?: string, replace?: string): string;
|
|
63
63
|
|
|
64
64
|
export { awaitedConfig, defaultPostPrompt, defaultPrePrompt, getConfigSource, isLocalConfigFound, loadUserConfig, postPrompt, prePrompt };
|
package/dist/config.mjs
CHANGED
|
@@ -51,12 +51,12 @@ var configSchema = z.object({
|
|
|
51
51
|
model: z.string().nullable(),
|
|
52
52
|
temperature: z.number().optional(),
|
|
53
53
|
sleep: z.number().optional(),
|
|
54
|
-
prePrompt: z.string().optional(),
|
|
55
|
-
postPrompt: z.string().optional(),
|
|
54
|
+
prePrompt: z.string().max(128).optional(),
|
|
55
|
+
postPrompt: z.string().max(128).optional(),
|
|
56
56
|
prePromptReplace: z.string().optional(),
|
|
57
57
|
postPromptReplace: z.string().optional(),
|
|
58
58
|
prePromptAppend: z.string().optional(),
|
|
59
|
-
|
|
59
|
+
postPromptPrepend: z.string().optional()
|
|
60
60
|
}),
|
|
61
61
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
62
62
|
}).refine(
|
|
@@ -88,8 +88,16 @@ async function loadUserConfig() {
|
|
|
88
88
|
try {
|
|
89
89
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
90
90
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
91
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
92
|
-
|
|
91
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
92
|
+
parsedConfig,
|
|
93
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
94
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
95
|
+
);
|
|
96
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
97
|
+
parsedConfig,
|
|
98
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
99
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
100
|
+
);
|
|
93
101
|
return parsedConfig;
|
|
94
102
|
} catch (error) {
|
|
95
103
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -138,16 +146,16 @@ function defaultPostPrompt(_config) {
|
|
|
138
146
|
[/POST-MESSAGE]
|
|
139
147
|
`;
|
|
140
148
|
}
|
|
141
|
-
function prePrompt(config) {
|
|
149
|
+
function prePrompt(config, append, replace) {
|
|
142
150
|
return [
|
|
143
|
-
|
|
144
|
-
|
|
151
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
152
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
145
153
|
].join(" ").trim();
|
|
146
154
|
}
|
|
147
|
-
function postPrompt(config) {
|
|
155
|
+
function postPrompt(config, prepend, replace) {
|
|
148
156
|
return [
|
|
149
|
-
|
|
150
|
-
|
|
157
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
158
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
151
159
|
].join(" ").trim();
|
|
152
160
|
}
|
|
153
161
|
|
package/dist/config.test.mjs
CHANGED
|
@@ -42,7 +42,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
42
42
|
mod
|
|
43
43
|
));
|
|
44
44
|
|
|
45
|
-
// ../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.
|
|
45
|
+
// ../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
46
46
|
function encodeInteger(builder, num, relative2) {
|
|
47
47
|
let delta = num - relative2;
|
|
48
48
|
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
@@ -81,7 +81,7 @@ function encode(decoded) {
|
|
|
81
81
|
}
|
|
82
82
|
var comma2, semicolon, chars2, intToChar2, charToInt2, bufLength, td, StringWriter;
|
|
83
83
|
var init_sourcemap_codec = __esm({
|
|
84
|
-
"../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.
|
|
84
|
+
"../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs"() {
|
|
85
85
|
comma2 = ",".charCodeAt(0);
|
|
86
86
|
semicolon = ";".charCodeAt(0);
|
|
87
87
|
chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -129,7 +129,7 @@ var init_sourcemap_codec = __esm({
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
// ../node_modules/.pnpm/magic-string@0.30.
|
|
132
|
+
// ../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs
|
|
133
133
|
var magic_string_es_exports = {};
|
|
134
134
|
__export(magic_string_es_exports, {
|
|
135
135
|
Bundle: () => Bundle,
|
|
@@ -205,7 +205,7 @@ function getLocator(source) {
|
|
|
205
205
|
}
|
|
206
206
|
var BitSet, Chunk, btoa, SourceMap, toString4, wordRegex, Mappings, n, warned, MagicString, hasOwnProp, Bundle;
|
|
207
207
|
var init_magic_string_es = __esm({
|
|
208
|
-
"../node_modules/.pnpm/magic-string@0.30.
|
|
208
|
+
"../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs"() {
|
|
209
209
|
init_sourcemap_codec();
|
|
210
210
|
BitSet = class _BitSet {
|
|
211
211
|
constructor(arg) {
|
|
@@ -576,6 +576,9 @@ var init_magic_string_es = __esm({
|
|
|
576
576
|
}
|
|
577
577
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
578
578
|
});
|
|
579
|
+
if (this.outro) {
|
|
580
|
+
mappings.advance(this.outro);
|
|
581
|
+
}
|
|
579
582
|
return {
|
|
580
583
|
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
581
584
|
sources: [
|
|
@@ -933,10 +936,13 @@ var init_magic_string_es = __esm({
|
|
|
933
936
|
_split(index) {
|
|
934
937
|
if (this.byStart[index] || this.byEnd[index]) return;
|
|
935
938
|
let chunk = this.lastSearchedChunk;
|
|
939
|
+
let previousChunk = chunk;
|
|
936
940
|
const searchForward = index > chunk.end;
|
|
937
941
|
while (chunk) {
|
|
938
942
|
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
939
943
|
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
944
|
+
if (chunk === previousChunk) return;
|
|
945
|
+
previousChunk = chunk;
|
|
940
946
|
}
|
|
941
947
|
}
|
|
942
948
|
_splitChunk(chunk, index) {
|
|
@@ -1083,7 +1089,12 @@ var init_magic_string_es = __esm({
|
|
|
1083
1089
|
const { original } = this;
|
|
1084
1090
|
const index = original.indexOf(string2);
|
|
1085
1091
|
if (index !== -1) {
|
|
1086
|
-
|
|
1092
|
+
if (typeof replacement === "function") {
|
|
1093
|
+
replacement = replacement(string2, index, original);
|
|
1094
|
+
}
|
|
1095
|
+
if (string2 !== replacement) {
|
|
1096
|
+
this.overwrite(index, index + string2.length, replacement);
|
|
1097
|
+
}
|
|
1087
1098
|
}
|
|
1088
1099
|
return this;
|
|
1089
1100
|
}
|
|
@@ -1098,7 +1109,11 @@ var init_magic_string_es = __esm({
|
|
|
1098
1109
|
const stringLength = string2.length;
|
|
1099
1110
|
for (let index = original.indexOf(string2); index !== -1; index = original.indexOf(string2, index + stringLength)) {
|
|
1100
1111
|
const previous = original.slice(index, index + stringLength);
|
|
1101
|
-
|
|
1112
|
+
let _replacement = replacement;
|
|
1113
|
+
if (typeof replacement === "function") {
|
|
1114
|
+
_replacement = replacement(previous, index, original);
|
|
1115
|
+
}
|
|
1116
|
+
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1102
1117
|
}
|
|
1103
1118
|
return this;
|
|
1104
1119
|
}
|
|
@@ -18153,12 +18168,12 @@ var configSchema = z.object({
|
|
|
18153
18168
|
model: z.string().nullable(),
|
|
18154
18169
|
temperature: z.number().optional(),
|
|
18155
18170
|
sleep: z.number().optional(),
|
|
18156
|
-
prePrompt: z.string().optional(),
|
|
18157
|
-
postPrompt: z.string().optional(),
|
|
18171
|
+
prePrompt: z.string().max(128).optional(),
|
|
18172
|
+
postPrompt: z.string().max(128).optional(),
|
|
18158
18173
|
prePromptReplace: z.string().optional(),
|
|
18159
18174
|
postPromptReplace: z.string().optional(),
|
|
18160
18175
|
prePromptAppend: z.string().optional(),
|
|
18161
|
-
|
|
18176
|
+
postPromptPrepend: z.string().optional()
|
|
18162
18177
|
}),
|
|
18163
18178
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
18164
18179
|
}).refine(
|
|
@@ -18184,8 +18199,16 @@ async function loadUserConfig() {
|
|
|
18184
18199
|
try {
|
|
18185
18200
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
18186
18201
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
18187
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
18188
|
-
|
|
18202
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
18203
|
+
parsedConfig,
|
|
18204
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
18205
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
18206
|
+
);
|
|
18207
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
18208
|
+
parsedConfig,
|
|
18209
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
18210
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
18211
|
+
);
|
|
18189
18212
|
return parsedConfig;
|
|
18190
18213
|
} catch (error) {
|
|
18191
18214
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -18234,16 +18257,16 @@ function defaultPostPrompt(_config) {
|
|
|
18234
18257
|
[/POST-MESSAGE]
|
|
18235
18258
|
`;
|
|
18236
18259
|
}
|
|
18237
|
-
function prePrompt(config2) {
|
|
18260
|
+
function prePrompt(config2, append, replace) {
|
|
18238
18261
|
return [
|
|
18239
|
-
|
|
18240
|
-
|
|
18262
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
18263
|
+
replace ? String(replace) : defaultPrePrompt(config2)
|
|
18241
18264
|
].join(" ").trim();
|
|
18242
18265
|
}
|
|
18243
|
-
function postPrompt(config2) {
|
|
18266
|
+
function postPrompt(config2, prepend, replace) {
|
|
18244
18267
|
return [
|
|
18245
|
-
|
|
18246
|
-
|
|
18268
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
18269
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
18247
18270
|
].join(" ").trim();
|
|
18248
18271
|
}
|
|
18249
18272
|
|
|
@@ -18290,9 +18313,7 @@ describe("config", () => {
|
|
|
18290
18313
|
const config2 = {
|
|
18291
18314
|
...defaultConfig,
|
|
18292
18315
|
llm: {
|
|
18293
|
-
...defaultConfig.llm
|
|
18294
|
-
prePromptReplace: "Custom pre-prompt"
|
|
18295
|
-
}
|
|
18316
|
+
...defaultConfig.llm}
|
|
18296
18317
|
};
|
|
18297
18318
|
const result2 = prePrompt(config2);
|
|
18298
18319
|
globalExpect(result2).toBe("Custom pre-prompt");
|
|
@@ -18301,9 +18322,7 @@ describe("config", () => {
|
|
|
18301
18322
|
const config2 = {
|
|
18302
18323
|
...defaultConfig,
|
|
18303
18324
|
llm: {
|
|
18304
|
-
...defaultConfig.llm
|
|
18305
|
-
prePromptAppend: "Additional instructions"
|
|
18306
|
-
}
|
|
18325
|
+
...defaultConfig.llm}
|
|
18307
18326
|
};
|
|
18308
18327
|
const result2 = prePrompt(config2);
|
|
18309
18328
|
globalExpect(result2).toContain("Additional instructions");
|
|
@@ -18313,13 +18332,10 @@ describe("config", () => {
|
|
|
18313
18332
|
const config2 = {
|
|
18314
18333
|
...defaultConfig,
|
|
18315
18334
|
llm: {
|
|
18316
|
-
...defaultConfig.llm
|
|
18317
|
-
prePromptReplace: "Custom pre-prompt",
|
|
18318
|
-
prePromptAppend: "Additional instructions"
|
|
18319
|
-
}
|
|
18335
|
+
...defaultConfig.llm}
|
|
18320
18336
|
};
|
|
18321
18337
|
const result2 = prePrompt(config2);
|
|
18322
|
-
globalExpect(result2).toBe("Custom pre-prompt
|
|
18338
|
+
globalExpect(result2).toBe("Custom pre-prompt Additional instructions");
|
|
18323
18339
|
});
|
|
18324
18340
|
it("should use default prompt when no customization is provided", () => {
|
|
18325
18341
|
const config2 = {
|
|
@@ -18332,45 +18348,38 @@ describe("config", () => {
|
|
|
18332
18348
|
});
|
|
18333
18349
|
describe("postPrompt", () => {
|
|
18334
18350
|
it("should use postPromptReplace when provided", () => {
|
|
18335
|
-
|
|
18351
|
+
({
|
|
18336
18352
|
...defaultConfig,
|
|
18337
18353
|
llm: {
|
|
18338
|
-
...defaultConfig.llm
|
|
18339
|
-
|
|
18340
|
-
|
|
18341
|
-
};
|
|
18342
|
-
const result2 = postPrompt(config2);
|
|
18354
|
+
...defaultConfig.llm}
|
|
18355
|
+
});
|
|
18356
|
+
const result2 = postPrompt();
|
|
18343
18357
|
globalExpect(result2).toBe("Custom post-prompt");
|
|
18344
18358
|
});
|
|
18345
|
-
it("should use
|
|
18346
|
-
|
|
18359
|
+
it("should use postPromptPrepend when provided", () => {
|
|
18360
|
+
({
|
|
18347
18361
|
...defaultConfig,
|
|
18348
18362
|
llm: {
|
|
18349
|
-
...defaultConfig.llm
|
|
18350
|
-
|
|
18351
|
-
|
|
18352
|
-
};
|
|
18353
|
-
const result2 = postPrompt(config2);
|
|
18363
|
+
...defaultConfig.llm}
|
|
18364
|
+
});
|
|
18365
|
+
const result2 = postPrompt();
|
|
18354
18366
|
globalExpect(result2).toContain("Additional post instructions");
|
|
18355
18367
|
globalExpect(result2).toContain("[POST-MESSAGE]");
|
|
18356
18368
|
});
|
|
18357
|
-
it("should use postPromptReplace and
|
|
18358
|
-
|
|
18369
|
+
it("should use postPromptReplace and postPromptPrepend together", () => {
|
|
18370
|
+
({
|
|
18359
18371
|
...defaultConfig,
|
|
18360
18372
|
llm: {
|
|
18361
|
-
...defaultConfig.llm
|
|
18362
|
-
|
|
18363
|
-
|
|
18364
|
-
|
|
18365
|
-
};
|
|
18366
|
-
const result2 = postPrompt(config2);
|
|
18367
|
-
globalExpect(result2).toBe("Custom post-prompt Additional post instructions");
|
|
18373
|
+
...defaultConfig.llm}
|
|
18374
|
+
});
|
|
18375
|
+
const result2 = postPrompt();
|
|
18376
|
+
globalExpect(result2).toBe("Additional post instructions Custom post-prompt");
|
|
18368
18377
|
});
|
|
18369
18378
|
it("should use default prompt when no customization is provided", () => {
|
|
18370
|
-
|
|
18379
|
+
({
|
|
18371
18380
|
...defaultConfig
|
|
18372
|
-
};
|
|
18373
|
-
const result2 = postPrompt(
|
|
18381
|
+
});
|
|
18382
|
+
const result2 = postPrompt();
|
|
18374
18383
|
globalExpect(result2).toContain("[POST-MESSAGE]");
|
|
18375
18384
|
globalExpect(result2).toContain("[/POST-MESSAGE]");
|
|
18376
18385
|
});
|
|
@@ -54,12 +54,12 @@ var configSchema = z.object({
|
|
|
54
54
|
model: z.string().nullable(),
|
|
55
55
|
temperature: z.number().optional(),
|
|
56
56
|
sleep: z.number().optional(),
|
|
57
|
-
prePrompt: z.string().optional(),
|
|
58
|
-
postPrompt: z.string().optional(),
|
|
57
|
+
prePrompt: z.string().max(128).optional(),
|
|
58
|
+
postPrompt: z.string().max(128).optional(),
|
|
59
59
|
prePromptReplace: z.string().optional(),
|
|
60
60
|
postPromptReplace: z.string().optional(),
|
|
61
61
|
prePromptAppend: z.string().optional(),
|
|
62
|
-
|
|
62
|
+
postPromptPrepend: z.string().optional()
|
|
63
63
|
}),
|
|
64
64
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
65
65
|
}).refine(
|
|
@@ -85,8 +85,16 @@ async function loadUserConfig() {
|
|
|
85
85
|
try {
|
|
86
86
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
87
87
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
88
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
-
|
|
88
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
+
parsedConfig,
|
|
90
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
91
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
92
|
+
);
|
|
93
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
94
|
+
parsedConfig,
|
|
95
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
96
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
97
|
+
);
|
|
90
98
|
return parsedConfig;
|
|
91
99
|
} catch (error) {
|
|
92
100
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
|
|
|
135
143
|
[/POST-MESSAGE]
|
|
136
144
|
`;
|
|
137
145
|
}
|
|
138
|
-
function prePrompt(config) {
|
|
146
|
+
function prePrompt(config, append, replace) {
|
|
139
147
|
return [
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
149
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
142
150
|
].join(" ").trim();
|
|
143
151
|
}
|
|
144
|
-
function postPrompt(config) {
|
|
152
|
+
function postPrompt(config, prepend, replace) {
|
|
145
153
|
return [
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
155
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
148
156
|
].join(" ").trim();
|
|
149
157
|
}
|
|
150
158
|
var optsArg = (opts) => {
|
|
@@ -54,12 +54,12 @@ var configSchema = z.object({
|
|
|
54
54
|
model: z.string().nullable(),
|
|
55
55
|
temperature: z.number().optional(),
|
|
56
56
|
sleep: z.number().optional(),
|
|
57
|
-
prePrompt: z.string().optional(),
|
|
58
|
-
postPrompt: z.string().optional(),
|
|
57
|
+
prePrompt: z.string().max(128).optional(),
|
|
58
|
+
postPrompt: z.string().max(128).optional(),
|
|
59
59
|
prePromptReplace: z.string().optional(),
|
|
60
60
|
postPromptReplace: z.string().optional(),
|
|
61
61
|
prePromptAppend: z.string().optional(),
|
|
62
|
-
|
|
62
|
+
postPromptPrepend: z.string().optional()
|
|
63
63
|
}),
|
|
64
64
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
65
65
|
}).refine(
|
|
@@ -85,8 +85,16 @@ async function loadUserConfig() {
|
|
|
85
85
|
try {
|
|
86
86
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
87
87
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
88
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
-
|
|
88
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
+
parsedConfig,
|
|
90
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
91
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
92
|
+
);
|
|
93
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
94
|
+
parsedConfig,
|
|
95
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
96
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
97
|
+
);
|
|
90
98
|
return parsedConfig;
|
|
91
99
|
} catch (error) {
|
|
92
100
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
|
|
|
135
143
|
[/POST-MESSAGE]
|
|
136
144
|
`;
|
|
137
145
|
}
|
|
138
|
-
function prePrompt(config) {
|
|
146
|
+
function prePrompt(config, append, replace) {
|
|
139
147
|
return [
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
149
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
142
150
|
].join(" ").trim();
|
|
143
151
|
}
|
|
144
|
-
function postPrompt(config) {
|
|
152
|
+
function postPrompt(config, prepend, replace) {
|
|
145
153
|
return [
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
155
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
148
156
|
].join(" ").trim();
|
|
149
157
|
}
|
|
150
158
|
var optsArg = (opts) => {
|
|
@@ -258,12 +258,12 @@ var configSchema = z.object({
|
|
|
258
258
|
model: z.string().nullable(),
|
|
259
259
|
temperature: z.number().optional(),
|
|
260
260
|
sleep: z.number().optional(),
|
|
261
|
-
prePrompt: z.string().optional(),
|
|
262
|
-
postPrompt: z.string().optional(),
|
|
261
|
+
prePrompt: z.string().max(128).optional(),
|
|
262
|
+
postPrompt: z.string().max(128).optional(),
|
|
263
263
|
prePromptReplace: z.string().optional(),
|
|
264
264
|
postPromptReplace: z.string().optional(),
|
|
265
265
|
prePromptAppend: z.string().optional(),
|
|
266
|
-
|
|
266
|
+
postPromptPrepend: z.string().optional()
|
|
267
267
|
}),
|
|
268
268
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
269
269
|
}).refine(
|
|
@@ -289,8 +289,16 @@ async function loadUserConfig() {
|
|
|
289
289
|
try {
|
|
290
290
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
291
291
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
292
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
293
|
-
|
|
292
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
293
|
+
parsedConfig,
|
|
294
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
295
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
296
|
+
);
|
|
297
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
298
|
+
parsedConfig,
|
|
299
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
300
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
301
|
+
);
|
|
294
302
|
return parsedConfig;
|
|
295
303
|
} catch (error) {
|
|
296
304
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -339,16 +347,16 @@ function defaultPostPrompt(_config) {
|
|
|
339
347
|
[/POST-MESSAGE]
|
|
340
348
|
`;
|
|
341
349
|
}
|
|
342
|
-
function prePrompt(config) {
|
|
350
|
+
function prePrompt(config, append, replace) {
|
|
343
351
|
return [
|
|
344
|
-
|
|
345
|
-
|
|
352
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
353
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
346
354
|
].join(" ").trim();
|
|
347
355
|
}
|
|
348
|
-
function postPrompt(config) {
|
|
356
|
+
function postPrompt(config, prepend, replace) {
|
|
349
357
|
return [
|
|
350
|
-
|
|
351
|
-
|
|
358
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
359
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
352
360
|
].join(" ").trim();
|
|
353
361
|
}
|
|
354
362
|
|
|
@@ -54,12 +54,12 @@ var configSchema = z.object({
|
|
|
54
54
|
model: z.string().nullable(),
|
|
55
55
|
temperature: z.number().optional(),
|
|
56
56
|
sleep: z.number().optional(),
|
|
57
|
-
prePrompt: z.string().optional(),
|
|
58
|
-
postPrompt: z.string().optional(),
|
|
57
|
+
prePrompt: z.string().max(128).optional(),
|
|
58
|
+
postPrompt: z.string().max(128).optional(),
|
|
59
59
|
prePromptReplace: z.string().optional(),
|
|
60
60
|
postPromptReplace: z.string().optional(),
|
|
61
61
|
prePromptAppend: z.string().optional(),
|
|
62
|
-
|
|
62
|
+
postPromptPrepend: z.string().optional()
|
|
63
63
|
}),
|
|
64
64
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
65
65
|
}).refine(
|
|
@@ -85,8 +85,16 @@ async function loadUserConfig() {
|
|
|
85
85
|
try {
|
|
86
86
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
87
87
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
88
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
-
|
|
88
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
+
parsedConfig,
|
|
90
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
91
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
92
|
+
);
|
|
93
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
94
|
+
parsedConfig,
|
|
95
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
96
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
97
|
+
);
|
|
90
98
|
return parsedConfig;
|
|
91
99
|
} catch (error) {
|
|
92
100
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
|
|
|
135
143
|
[/POST-MESSAGE]
|
|
136
144
|
`;
|
|
137
145
|
}
|
|
138
|
-
function prePrompt(config) {
|
|
146
|
+
function prePrompt(config, append, replace) {
|
|
139
147
|
return [
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
149
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
142
150
|
].join(" ").trim();
|
|
143
151
|
}
|
|
144
|
-
function postPrompt(config) {
|
|
152
|
+
function postPrompt(config, prepend, replace) {
|
|
145
153
|
return [
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
155
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
148
156
|
].join(" ").trim();
|
|
149
157
|
}
|
|
150
158
|
var optsArg = (opts) => {
|
package/dist/data/get-cache.mjs
CHANGED
|
@@ -54,12 +54,12 @@ var configSchema = z.object({
|
|
|
54
54
|
model: z.string().nullable(),
|
|
55
55
|
temperature: z.number().optional(),
|
|
56
56
|
sleep: z.number().optional(),
|
|
57
|
-
prePrompt: z.string().optional(),
|
|
58
|
-
postPrompt: z.string().optional(),
|
|
57
|
+
prePrompt: z.string().max(128).optional(),
|
|
58
|
+
postPrompt: z.string().max(128).optional(),
|
|
59
59
|
prePromptReplace: z.string().optional(),
|
|
60
60
|
postPromptReplace: z.string().optional(),
|
|
61
61
|
prePromptAppend: z.string().optional(),
|
|
62
|
-
|
|
62
|
+
postPromptPrepend: z.string().optional()
|
|
63
63
|
}),
|
|
64
64
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
65
65
|
}).refine(
|
|
@@ -85,8 +85,16 @@ async function loadUserConfig() {
|
|
|
85
85
|
try {
|
|
86
86
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
87
87
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
88
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
-
|
|
88
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
89
|
+
parsedConfig,
|
|
90
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
91
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
92
|
+
);
|
|
93
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
94
|
+
parsedConfig,
|
|
95
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
96
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
97
|
+
);
|
|
90
98
|
return parsedConfig;
|
|
91
99
|
} catch (error) {
|
|
92
100
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -135,16 +143,16 @@ function defaultPostPrompt(_config) {
|
|
|
135
143
|
[/POST-MESSAGE]
|
|
136
144
|
`;
|
|
137
145
|
}
|
|
138
|
-
function prePrompt(config) {
|
|
146
|
+
function prePrompt(config, append, replace) {
|
|
139
147
|
return [
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
149
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
142
150
|
].join(" ").trim();
|
|
143
151
|
}
|
|
144
|
-
function postPrompt(config) {
|
|
152
|
+
function postPrompt(config, prepend, replace) {
|
|
145
153
|
return [
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
155
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
148
156
|
].join(" ").trim();
|
|
149
157
|
}
|
|
150
158
|
var optsArg = (opts) => {
|