@gringow/gringow 0.0.9 → 0.1.1
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 +41 -47
- 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/gringow.d.mts +1 -1
- package/dist/gringow.mjs +80 -39
- package/dist/index.d.mts +5 -1
- package/dist/index.mjs +80 -39
- 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 +43 -34
- 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 +19 -11
- package/dist/io/huggingface/index.mjs +19 -11
- 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 +1 -1
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
|
-
temperature?: number | undefined;
|
|
48
|
-
sleep?: number | undefined;
|
|
49
47
|
prePrompt?: string | undefined;
|
|
50
48
|
postPrompt?: string | undefined;
|
|
49
|
+
temperature?: number | undefined;
|
|
50
|
+
sleep?: number | 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
|
@@ -18168,12 +18168,12 @@ var configSchema = z.object({
|
|
|
18168
18168
|
model: z.string().nullable(),
|
|
18169
18169
|
temperature: z.number().optional(),
|
|
18170
18170
|
sleep: z.number().optional(),
|
|
18171
|
-
prePrompt: z.string().optional(),
|
|
18172
|
-
postPrompt: z.string().optional(),
|
|
18171
|
+
prePrompt: z.string().max(128).optional(),
|
|
18172
|
+
postPrompt: z.string().max(128).optional(),
|
|
18173
18173
|
prePromptReplace: z.string().optional(),
|
|
18174
18174
|
postPromptReplace: z.string().optional(),
|
|
18175
18175
|
prePromptAppend: z.string().optional(),
|
|
18176
|
-
|
|
18176
|
+
postPromptPrepend: z.string().optional()
|
|
18177
18177
|
}),
|
|
18178
18178
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
18179
18179
|
}).refine(
|
|
@@ -18199,8 +18199,16 @@ async function loadUserConfig() {
|
|
|
18199
18199
|
try {
|
|
18200
18200
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
18201
18201
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
18202
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
18203
|
-
|
|
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
|
+
);
|
|
18204
18212
|
return parsedConfig;
|
|
18205
18213
|
} catch (error) {
|
|
18206
18214
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -18249,16 +18257,16 @@ function defaultPostPrompt(_config) {
|
|
|
18249
18257
|
[/POST-MESSAGE]
|
|
18250
18258
|
`;
|
|
18251
18259
|
}
|
|
18252
|
-
function prePrompt(config2) {
|
|
18260
|
+
function prePrompt(config2, append, replace) {
|
|
18253
18261
|
return [
|
|
18254
|
-
|
|
18255
|
-
|
|
18262
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
18263
|
+
replace ? String(replace) : defaultPrePrompt(config2)
|
|
18256
18264
|
].join(" ").trim();
|
|
18257
18265
|
}
|
|
18258
|
-
function postPrompt(config2) {
|
|
18266
|
+
function postPrompt(config2, prepend, replace) {
|
|
18259
18267
|
return [
|
|
18260
|
-
|
|
18261
|
-
|
|
18268
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
18269
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
18262
18270
|
].join(" ").trim();
|
|
18263
18271
|
}
|
|
18264
18272
|
|
|
@@ -18305,9 +18313,7 @@ describe("config", () => {
|
|
|
18305
18313
|
const config2 = {
|
|
18306
18314
|
...defaultConfig,
|
|
18307
18315
|
llm: {
|
|
18308
|
-
...defaultConfig.llm
|
|
18309
|
-
prePromptReplace: "Custom pre-prompt"
|
|
18310
|
-
}
|
|
18316
|
+
...defaultConfig.llm}
|
|
18311
18317
|
};
|
|
18312
18318
|
const result2 = prePrompt(config2);
|
|
18313
18319
|
globalExpect(result2).toBe("Custom pre-prompt");
|
|
@@ -18316,9 +18322,7 @@ describe("config", () => {
|
|
|
18316
18322
|
const config2 = {
|
|
18317
18323
|
...defaultConfig,
|
|
18318
18324
|
llm: {
|
|
18319
|
-
...defaultConfig.llm
|
|
18320
|
-
prePromptAppend: "Additional instructions"
|
|
18321
|
-
}
|
|
18325
|
+
...defaultConfig.llm}
|
|
18322
18326
|
};
|
|
18323
18327
|
const result2 = prePrompt(config2);
|
|
18324
18328
|
globalExpect(result2).toContain("Additional instructions");
|
|
@@ -18328,13 +18332,10 @@ describe("config", () => {
|
|
|
18328
18332
|
const config2 = {
|
|
18329
18333
|
...defaultConfig,
|
|
18330
18334
|
llm: {
|
|
18331
|
-
...defaultConfig.llm
|
|
18332
|
-
prePromptReplace: "Custom pre-prompt",
|
|
18333
|
-
prePromptAppend: "Additional instructions"
|
|
18334
|
-
}
|
|
18335
|
+
...defaultConfig.llm}
|
|
18335
18336
|
};
|
|
18336
18337
|
const result2 = prePrompt(config2);
|
|
18337
|
-
globalExpect(result2).toBe("Custom pre-prompt
|
|
18338
|
+
globalExpect(result2).toBe("Custom pre-prompt Additional instructions");
|
|
18338
18339
|
});
|
|
18339
18340
|
it("should use default prompt when no customization is provided", () => {
|
|
18340
18341
|
const config2 = {
|
|
@@ -18347,45 +18348,38 @@ describe("config", () => {
|
|
|
18347
18348
|
});
|
|
18348
18349
|
describe("postPrompt", () => {
|
|
18349
18350
|
it("should use postPromptReplace when provided", () => {
|
|
18350
|
-
|
|
18351
|
+
({
|
|
18351
18352
|
...defaultConfig,
|
|
18352
18353
|
llm: {
|
|
18353
|
-
...defaultConfig.llm
|
|
18354
|
-
|
|
18355
|
-
|
|
18356
|
-
};
|
|
18357
|
-
const result2 = postPrompt(config2);
|
|
18354
|
+
...defaultConfig.llm}
|
|
18355
|
+
});
|
|
18356
|
+
const result2 = postPrompt();
|
|
18358
18357
|
globalExpect(result2).toBe("Custom post-prompt");
|
|
18359
18358
|
});
|
|
18360
|
-
it("should use
|
|
18361
|
-
|
|
18359
|
+
it("should use postPromptPrepend when provided", () => {
|
|
18360
|
+
({
|
|
18362
18361
|
...defaultConfig,
|
|
18363
18362
|
llm: {
|
|
18364
|
-
...defaultConfig.llm
|
|
18365
|
-
|
|
18366
|
-
|
|
18367
|
-
};
|
|
18368
|
-
const result2 = postPrompt(config2);
|
|
18363
|
+
...defaultConfig.llm}
|
|
18364
|
+
});
|
|
18365
|
+
const result2 = postPrompt();
|
|
18369
18366
|
globalExpect(result2).toContain("Additional post instructions");
|
|
18370
18367
|
globalExpect(result2).toContain("[POST-MESSAGE]");
|
|
18371
18368
|
});
|
|
18372
|
-
it("should use postPromptReplace and
|
|
18373
|
-
|
|
18369
|
+
it("should use postPromptReplace and postPromptPrepend together", () => {
|
|
18370
|
+
({
|
|
18374
18371
|
...defaultConfig,
|
|
18375
18372
|
llm: {
|
|
18376
|
-
...defaultConfig.llm
|
|
18377
|
-
|
|
18378
|
-
|
|
18379
|
-
|
|
18380
|
-
};
|
|
18381
|
-
const result2 = postPrompt(config2);
|
|
18382
|
-
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");
|
|
18383
18377
|
});
|
|
18384
18378
|
it("should use default prompt when no customization is provided", () => {
|
|
18385
|
-
|
|
18379
|
+
({
|
|
18386
18380
|
...defaultConfig
|
|
18387
|
-
};
|
|
18388
|
-
const result2 = postPrompt(
|
|
18381
|
+
});
|
|
18382
|
+
const result2 = postPrompt();
|
|
18389
18383
|
globalExpect(result2).toContain("[POST-MESSAGE]");
|
|
18390
18384
|
globalExpect(result2).toContain("[/POST-MESSAGE]");
|
|
18391
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) => {
|
|
@@ -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/save-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) => {
|