@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/io/gemini/ask.mjs
CHANGED
|
@@ -52,12 +52,12 @@ var configSchema = z.object({
|
|
|
52
52
|
model: z.string().nullable(),
|
|
53
53
|
temperature: z.number().optional(),
|
|
54
54
|
sleep: z.number().optional(),
|
|
55
|
-
prePrompt: z.string().optional(),
|
|
56
|
-
postPrompt: z.string().optional(),
|
|
55
|
+
prePrompt: z.string().max(128).optional(),
|
|
56
|
+
postPrompt: z.string().max(128).optional(),
|
|
57
57
|
prePromptReplace: z.string().optional(),
|
|
58
58
|
postPromptReplace: z.string().optional(),
|
|
59
59
|
prePromptAppend: z.string().optional(),
|
|
60
|
-
|
|
60
|
+
postPromptPrepend: z.string().optional()
|
|
61
61
|
}),
|
|
62
62
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
63
63
|
}).refine(
|
|
@@ -83,8 +83,16 @@ async function loadUserConfig() {
|
|
|
83
83
|
try {
|
|
84
84
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
85
85
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
86
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
87
|
-
|
|
86
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
87
|
+
parsedConfig,
|
|
88
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
89
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
90
|
+
);
|
|
91
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
92
|
+
parsedConfig,
|
|
93
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
94
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
95
|
+
);
|
|
88
96
|
return parsedConfig;
|
|
89
97
|
} catch (error) {
|
|
90
98
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -133,21 +141,21 @@ function defaultPostPrompt(_config) {
|
|
|
133
141
|
[/POST-MESSAGE]
|
|
134
142
|
`;
|
|
135
143
|
}
|
|
136
|
-
function prePrompt(config) {
|
|
144
|
+
function prePrompt(config, append, replace) {
|
|
137
145
|
return [
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
147
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
140
148
|
].join(" ").trim();
|
|
141
149
|
}
|
|
142
|
-
function postPrompt(config) {
|
|
150
|
+
function postPrompt(config, prepend, replace) {
|
|
143
151
|
return [
|
|
144
|
-
|
|
145
|
-
|
|
152
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
153
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
146
154
|
].join(" ").trim();
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
// src/io/gemini/ask.ts
|
|
150
|
-
async function generateResponse(
|
|
158
|
+
async function generateResponse(prompt, temperature = 1) {
|
|
151
159
|
const config = await awaitedConfig;
|
|
152
160
|
if (!config.keys.geminiApiKey) {
|
|
153
161
|
throw new Error("Gemini API key is not set in the config");
|
|
@@ -159,20 +167,13 @@ async function generateResponse(message, temperature = 1) {
|
|
|
159
167
|
temperature
|
|
160
168
|
}
|
|
161
169
|
});
|
|
162
|
-
const prompt = String(`${config.llm.prePrompt}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
${message}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
${config.llm.postPrompt}`).trim();
|
|
169
170
|
if (config.debug) {
|
|
170
171
|
console.log("Gemini model prompt:", JSON.stringify({ prompt }));
|
|
171
172
|
}
|
|
172
173
|
const response = await model.generateContent([prompt]);
|
|
173
174
|
return response;
|
|
174
175
|
}
|
|
175
|
-
async function askGemini(
|
|
176
|
+
async function askGemini(prompt, prePrompt2, postPrompt2) {
|
|
176
177
|
const config = await awaitedConfig;
|
|
177
178
|
if (Number(config.llm.sleep)) {
|
|
178
179
|
await new Promise((resolve) => setTimeout(resolve, config.llm.sleep ?? 1));
|
|
@@ -181,11 +182,18 @@ async function askGemini(message) {
|
|
|
181
182
|
throw new Error("Gemini API key is not set in the config");
|
|
182
183
|
}
|
|
183
184
|
if (config.debug) {
|
|
184
|
-
console.log("\nAsking Gemini model:", JSON.stringify({ model: config.llm.model, message }));
|
|
185
|
+
console.log("\nAsking Gemini model:", JSON.stringify({ model: config.llm.model, message: prompt }));
|
|
185
186
|
}
|
|
187
|
+
const fullPrompt = String(`${prePrompt2}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
${prompt}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
${postPrompt2}`).trim();
|
|
186
194
|
let response;
|
|
187
195
|
for (let i = 0; i < 3; i++) {
|
|
188
|
-
const maybeResponse = await generateResponse(
|
|
196
|
+
const maybeResponse = await generateResponse(fullPrompt, config.llm.temperature);
|
|
189
197
|
if (!String(maybeResponse.response.candidates?.[0]?.content?.parts?.[0]?.text ?? "").includes("```json")) {
|
|
190
198
|
response = maybeResponse;
|
|
191
199
|
break;
|
package/dist/io/gemini/index.mjs
CHANGED
|
@@ -52,12 +52,12 @@ var configSchema = z.object({
|
|
|
52
52
|
model: z.string().nullable(),
|
|
53
53
|
temperature: z.number().optional(),
|
|
54
54
|
sleep: z.number().optional(),
|
|
55
|
-
prePrompt: z.string().optional(),
|
|
56
|
-
postPrompt: z.string().optional(),
|
|
55
|
+
prePrompt: z.string().max(128).optional(),
|
|
56
|
+
postPrompt: z.string().max(128).optional(),
|
|
57
57
|
prePromptReplace: z.string().optional(),
|
|
58
58
|
postPromptReplace: z.string().optional(),
|
|
59
59
|
prePromptAppend: z.string().optional(),
|
|
60
|
-
|
|
60
|
+
postPromptPrepend: z.string().optional()
|
|
61
61
|
}),
|
|
62
62
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
63
63
|
}).refine(
|
|
@@ -83,8 +83,16 @@ async function loadUserConfig() {
|
|
|
83
83
|
try {
|
|
84
84
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
85
85
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
86
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
87
|
-
|
|
86
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
87
|
+
parsedConfig,
|
|
88
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
89
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
90
|
+
);
|
|
91
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
92
|
+
parsedConfig,
|
|
93
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
94
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
95
|
+
);
|
|
88
96
|
return parsedConfig;
|
|
89
97
|
} catch (error) {
|
|
90
98
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -133,21 +141,21 @@ function defaultPostPrompt(_config) {
|
|
|
133
141
|
[/POST-MESSAGE]
|
|
134
142
|
`;
|
|
135
143
|
}
|
|
136
|
-
function prePrompt(config) {
|
|
144
|
+
function prePrompt(config, append, replace) {
|
|
137
145
|
return [
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
147
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
140
148
|
].join(" ").trim();
|
|
141
149
|
}
|
|
142
|
-
function postPrompt(config) {
|
|
150
|
+
function postPrompt(config, prepend, replace) {
|
|
143
151
|
return [
|
|
144
|
-
|
|
145
|
-
|
|
152
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
153
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
146
154
|
].join(" ").trim();
|
|
147
155
|
}
|
|
148
156
|
|
|
149
157
|
// src/io/gemini/ask.ts
|
|
150
|
-
async function generateResponse(
|
|
158
|
+
async function generateResponse(prompt, temperature = 1) {
|
|
151
159
|
const config = await awaitedConfig;
|
|
152
160
|
if (!config.keys.geminiApiKey) {
|
|
153
161
|
throw new Error("Gemini API key is not set in the config");
|
|
@@ -159,20 +167,13 @@ async function generateResponse(message, temperature = 1) {
|
|
|
159
167
|
temperature
|
|
160
168
|
}
|
|
161
169
|
});
|
|
162
|
-
const prompt = String(`${config.llm.prePrompt}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
${message}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
${config.llm.postPrompt}`).trim();
|
|
169
170
|
if (config.debug) {
|
|
170
171
|
console.log("Gemini model prompt:", JSON.stringify({ prompt }));
|
|
171
172
|
}
|
|
172
173
|
const response = await model.generateContent([prompt]);
|
|
173
174
|
return response;
|
|
174
175
|
}
|
|
175
|
-
async function askGemini(
|
|
176
|
+
async function askGemini(prompt, prePrompt2, postPrompt2) {
|
|
176
177
|
const config = await awaitedConfig;
|
|
177
178
|
if (Number(config.llm.sleep)) {
|
|
178
179
|
await new Promise((resolve) => setTimeout(resolve, config.llm.sleep ?? 1));
|
|
@@ -181,11 +182,18 @@ async function askGemini(message) {
|
|
|
181
182
|
throw new Error("Gemini API key is not set in the config");
|
|
182
183
|
}
|
|
183
184
|
if (config.debug) {
|
|
184
|
-
console.log("\nAsking Gemini model:", JSON.stringify({ model: config.llm.model, message }));
|
|
185
|
+
console.log("\nAsking Gemini model:", JSON.stringify({ model: config.llm.model, message: prompt }));
|
|
185
186
|
}
|
|
187
|
+
const fullPrompt = String(`${prePrompt2}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
${prompt}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
${postPrompt2}`).trim();
|
|
186
194
|
let response;
|
|
187
195
|
for (let i = 0; i < 3; i++) {
|
|
188
|
-
const maybeResponse = await generateResponse(
|
|
196
|
+
const maybeResponse = await generateResponse(fullPrompt, config.llm.temperature);
|
|
189
197
|
if (!String(maybeResponse.response.candidates?.[0]?.content?.parts?.[0]?.text ?? "").includes("```json")) {
|
|
190
198
|
response = maybeResponse;
|
|
191
199
|
break;
|
|
@@ -53,12 +53,12 @@ var configSchema = z.object({
|
|
|
53
53
|
model: z.string().nullable(),
|
|
54
54
|
temperature: z.number().optional(),
|
|
55
55
|
sleep: z.number().optional(),
|
|
56
|
-
prePrompt: z.string().optional(),
|
|
57
|
-
postPrompt: z.string().optional(),
|
|
56
|
+
prePrompt: z.string().max(128).optional(),
|
|
57
|
+
postPrompt: z.string().max(128).optional(),
|
|
58
58
|
prePromptReplace: z.string().optional(),
|
|
59
59
|
postPromptReplace: z.string().optional(),
|
|
60
60
|
prePromptAppend: z.string().optional(),
|
|
61
|
-
|
|
61
|
+
postPromptPrepend: z.string().optional()
|
|
62
62
|
}),
|
|
63
63
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
64
64
|
}).refine(
|
|
@@ -84,8 +84,16 @@ async function loadUserConfig() {
|
|
|
84
84
|
try {
|
|
85
85
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
86
86
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
87
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
88
|
-
|
|
87
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
88
|
+
parsedConfig,
|
|
89
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
90
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
91
|
+
);
|
|
92
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
93
|
+
parsedConfig,
|
|
94
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
95
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
96
|
+
);
|
|
89
97
|
return parsedConfig;
|
|
90
98
|
} catch (error) {
|
|
91
99
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -134,20 +142,20 @@ function defaultPostPrompt(_config) {
|
|
|
134
142
|
[/POST-MESSAGE]
|
|
135
143
|
`;
|
|
136
144
|
}
|
|
137
|
-
function prePrompt(config) {
|
|
145
|
+
function prePrompt(config, append, replace) {
|
|
138
146
|
return [
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
148
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
141
149
|
].join(" ").trim();
|
|
142
150
|
}
|
|
143
|
-
function postPrompt(config) {
|
|
151
|
+
function postPrompt(config, prepend, replace) {
|
|
144
152
|
return [
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
154
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
147
155
|
].join(" ").trim();
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
// src/io/huggingface/
|
|
158
|
+
// src/io/huggingface/languages-map.ts
|
|
151
159
|
var languagesMap = {
|
|
152
160
|
"en-US": "eng_Latn",
|
|
153
161
|
"en-GB": "eng_Latn",
|
|
@@ -53,12 +53,12 @@ var configSchema = z.object({
|
|
|
53
53
|
model: z.string().nullable(),
|
|
54
54
|
temperature: z.number().optional(),
|
|
55
55
|
sleep: z.number().optional(),
|
|
56
|
-
prePrompt: z.string().optional(),
|
|
57
|
-
postPrompt: z.string().optional(),
|
|
56
|
+
prePrompt: z.string().max(128).optional(),
|
|
57
|
+
postPrompt: z.string().max(128).optional(),
|
|
58
58
|
prePromptReplace: z.string().optional(),
|
|
59
59
|
postPromptReplace: z.string().optional(),
|
|
60
60
|
prePromptAppend: z.string().optional(),
|
|
61
|
-
|
|
61
|
+
postPromptPrepend: z.string().optional()
|
|
62
62
|
}),
|
|
63
63
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
64
64
|
}).refine(
|
|
@@ -84,8 +84,16 @@ async function loadUserConfig() {
|
|
|
84
84
|
try {
|
|
85
85
|
const mergedConfig = merge({}, defaultConfig, result?.config);
|
|
86
86
|
const parsedConfig = await configSchema.parseAsync(mergedConfig);
|
|
87
|
-
parsedConfig.llm.prePrompt = prePrompt(
|
|
88
|
-
|
|
87
|
+
parsedConfig.llm.prePrompt = prePrompt(
|
|
88
|
+
parsedConfig,
|
|
89
|
+
parsedConfig.llm.prePromptAppend ?? "",
|
|
90
|
+
parsedConfig.llm.prePromptReplace ?? ""
|
|
91
|
+
);
|
|
92
|
+
parsedConfig.llm.postPrompt = postPrompt(
|
|
93
|
+
parsedConfig,
|
|
94
|
+
parsedConfig.llm.postPromptPrepend ?? "",
|
|
95
|
+
parsedConfig.llm.postPromptReplace ?? ""
|
|
96
|
+
);
|
|
89
97
|
return parsedConfig;
|
|
90
98
|
} catch (error) {
|
|
91
99
|
console.warn(`${error?.message}, using default configuration`);
|
|
@@ -134,20 +142,20 @@ function defaultPostPrompt(_config) {
|
|
|
134
142
|
[/POST-MESSAGE]
|
|
135
143
|
`;
|
|
136
144
|
}
|
|
137
|
-
function prePrompt(config) {
|
|
145
|
+
function prePrompt(config, append, replace) {
|
|
138
146
|
return [
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
...append ? ["[SPECIFIC_INPUTS]", String(append), "[/SPECIFIC_INPUTS]"] : [],
|
|
148
|
+
replace ? String(replace) : defaultPrePrompt(config)
|
|
141
149
|
].join(" ").trim();
|
|
142
150
|
}
|
|
143
|
-
function postPrompt(config) {
|
|
151
|
+
function postPrompt(config, prepend, replace) {
|
|
144
152
|
return [
|
|
145
|
-
|
|
146
|
-
|
|
153
|
+
...prepend ? ["[SPECIFIC_INPUTS]", String(prepend), "[/SPECIFIC_INPUTS]"] : [],
|
|
154
|
+
replace ? String(replace) : defaultPostPrompt()
|
|
147
155
|
].join(" ").trim();
|
|
148
156
|
}
|
|
149
157
|
|
|
150
|
-
// src/io/huggingface/
|
|
158
|
+
// src/io/huggingface/languages-map.ts
|
|
151
159
|
var languagesMap = {
|
|
152
160
|
"en-US": "eng_Latn",
|
|
153
161
|
"en-GB": "eng_Latn",
|
package/dist/logger.test.mjs
CHANGED
|
@@ -39,7 +39,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
39
39
|
mod
|
|
40
40
|
));
|
|
41
41
|
|
|
42
|
-
// ../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.
|
|
42
|
+
// ../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
|
|
43
43
|
function encodeInteger(builder, num, relative2) {
|
|
44
44
|
let delta = num - relative2;
|
|
45
45
|
delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
|
|
@@ -78,7 +78,7 @@ function encode(decoded) {
|
|
|
78
78
|
}
|
|
79
79
|
var comma2, semicolon, chars2, intToChar2, charToInt2, bufLength, td, StringWriter;
|
|
80
80
|
var init_sourcemap_codec = __esm({
|
|
81
|
-
"../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.
|
|
81
|
+
"../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs"() {
|
|
82
82
|
comma2 = ",".charCodeAt(0);
|
|
83
83
|
semicolon = ";".charCodeAt(0);
|
|
84
84
|
chars2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -126,7 +126,7 @@ var init_sourcemap_codec = __esm({
|
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
// ../node_modules/.pnpm/magic-string@0.30.
|
|
129
|
+
// ../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs
|
|
130
130
|
var magic_string_es_exports = {};
|
|
131
131
|
__export(magic_string_es_exports, {
|
|
132
132
|
Bundle: () => Bundle,
|
|
@@ -202,7 +202,7 @@ function getLocator(source) {
|
|
|
202
202
|
}
|
|
203
203
|
var BitSet, Chunk, btoa, SourceMap, toString4, wordRegex, Mappings, n, warned, MagicString, hasOwnProp, Bundle;
|
|
204
204
|
var init_magic_string_es = __esm({
|
|
205
|
-
"../node_modules/.pnpm/magic-string@0.30.
|
|
205
|
+
"../node_modules/.pnpm/magic-string@0.30.19/node_modules/magic-string/dist/magic-string.es.mjs"() {
|
|
206
206
|
init_sourcemap_codec();
|
|
207
207
|
BitSet = class _BitSet {
|
|
208
208
|
constructor(arg) {
|
|
@@ -573,6 +573,9 @@ var init_magic_string_es = __esm({
|
|
|
573
573
|
}
|
|
574
574
|
if (chunk.outro.length) mappings.advance(chunk.outro);
|
|
575
575
|
});
|
|
576
|
+
if (this.outro) {
|
|
577
|
+
mappings.advance(this.outro);
|
|
578
|
+
}
|
|
576
579
|
return {
|
|
577
580
|
file: options.file ? options.file.split(/[/\\]/).pop() : void 0,
|
|
578
581
|
sources: [
|
|
@@ -930,10 +933,13 @@ var init_magic_string_es = __esm({
|
|
|
930
933
|
_split(index) {
|
|
931
934
|
if (this.byStart[index] || this.byEnd[index]) return;
|
|
932
935
|
let chunk = this.lastSearchedChunk;
|
|
936
|
+
let previousChunk = chunk;
|
|
933
937
|
const searchForward = index > chunk.end;
|
|
934
938
|
while (chunk) {
|
|
935
939
|
if (chunk.contains(index)) return this._splitChunk(chunk, index);
|
|
936
940
|
chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
|
|
941
|
+
if (chunk === previousChunk) return;
|
|
942
|
+
previousChunk = chunk;
|
|
937
943
|
}
|
|
938
944
|
}
|
|
939
945
|
_splitChunk(chunk, index) {
|
|
@@ -1080,7 +1086,12 @@ var init_magic_string_es = __esm({
|
|
|
1080
1086
|
const { original } = this;
|
|
1081
1087
|
const index = original.indexOf(string2);
|
|
1082
1088
|
if (index !== -1) {
|
|
1083
|
-
|
|
1089
|
+
if (typeof replacement === "function") {
|
|
1090
|
+
replacement = replacement(string2, index, original);
|
|
1091
|
+
}
|
|
1092
|
+
if (string2 !== replacement) {
|
|
1093
|
+
this.overwrite(index, index + string2.length, replacement);
|
|
1094
|
+
}
|
|
1084
1095
|
}
|
|
1085
1096
|
return this;
|
|
1086
1097
|
}
|
|
@@ -1095,7 +1106,11 @@ var init_magic_string_es = __esm({
|
|
|
1095
1106
|
const stringLength = string2.length;
|
|
1096
1107
|
for (let index = original.indexOf(string2); index !== -1; index = original.indexOf(string2, index + stringLength)) {
|
|
1097
1108
|
const previous = original.slice(index, index + stringLength);
|
|
1098
|
-
|
|
1109
|
+
let _replacement = replacement;
|
|
1110
|
+
if (typeof replacement === "function") {
|
|
1111
|
+
_replacement = replacement(previous, index, original);
|
|
1112
|
+
}
|
|
1113
|
+
if (previous !== _replacement) this.overwrite(index, index + stringLength, _replacement);
|
|
1099
1114
|
}
|
|
1100
1115
|
return this;
|
|
1101
1116
|
}
|
|
@@ -49,29 +49,29 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
49
49
|
prePromptReplace: z.ZodOptional<z.ZodString>;
|
|
50
50
|
postPromptReplace: z.ZodOptional<z.ZodString>;
|
|
51
51
|
prePromptAppend: z.ZodOptional<z.ZodString>;
|
|
52
|
-
|
|
52
|
+
postPromptPrepend: z.ZodOptional<z.ZodString>;
|
|
53
53
|
}, "strip", z.ZodTypeAny, {
|
|
54
54
|
choice: "gemini" | "anthropic" | "huggingface";
|
|
55
55
|
model: string | null;
|
|
56
|
-
prePrompt?: string | undefined;
|
|
57
|
-
postPrompt?: string | undefined;
|
|
58
56
|
temperature?: number | undefined;
|
|
59
57
|
sleep?: number | undefined;
|
|
58
|
+
prePrompt?: string | undefined;
|
|
59
|
+
postPrompt?: string | undefined;
|
|
60
60
|
prePromptReplace?: string | undefined;
|
|
61
61
|
postPromptReplace?: string | undefined;
|
|
62
62
|
prePromptAppend?: string | undefined;
|
|
63
|
-
|
|
63
|
+
postPromptPrepend?: string | undefined;
|
|
64
64
|
}, {
|
|
65
65
|
choice: "gemini" | "anthropic" | "huggingface";
|
|
66
66
|
model: string | null;
|
|
67
|
-
prePrompt?: string | undefined;
|
|
68
|
-
postPrompt?: string | undefined;
|
|
69
67
|
temperature?: number | undefined;
|
|
70
68
|
sleep?: number | undefined;
|
|
69
|
+
prePrompt?: string | undefined;
|
|
70
|
+
postPrompt?: string | undefined;
|
|
71
71
|
prePromptReplace?: string | undefined;
|
|
72
72
|
postPromptReplace?: string | undefined;
|
|
73
73
|
prePromptAppend?: string | undefined;
|
|
74
|
-
|
|
74
|
+
postPromptPrepend?: string | undefined;
|
|
75
75
|
}>;
|
|
76
76
|
globby: z.ZodOptional<z.ZodString>;
|
|
77
77
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -93,14 +93,14 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
93
93
|
llm: {
|
|
94
94
|
choice: "gemini" | "anthropic" | "huggingface";
|
|
95
95
|
model: string | null;
|
|
96
|
-
prePrompt?: string | undefined;
|
|
97
|
-
postPrompt?: string | undefined;
|
|
98
96
|
temperature?: number | undefined;
|
|
99
97
|
sleep?: number | undefined;
|
|
98
|
+
prePrompt?: string | undefined;
|
|
99
|
+
postPrompt?: string | undefined;
|
|
100
100
|
prePromptReplace?: string | undefined;
|
|
101
101
|
postPromptReplace?: string | undefined;
|
|
102
102
|
prePromptAppend?: string | undefined;
|
|
103
|
-
|
|
103
|
+
postPromptPrepend?: string | undefined;
|
|
104
104
|
};
|
|
105
105
|
debug?: boolean | undefined;
|
|
106
106
|
globby?: string | undefined;
|
|
@@ -123,14 +123,14 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
123
123
|
llm: {
|
|
124
124
|
choice: "gemini" | "anthropic" | "huggingface";
|
|
125
125
|
model: string | null;
|
|
126
|
-
prePrompt?: string | undefined;
|
|
127
|
-
postPrompt?: string | undefined;
|
|
128
126
|
temperature?: number | undefined;
|
|
129
127
|
sleep?: number | undefined;
|
|
128
|
+
prePrompt?: string | undefined;
|
|
129
|
+
postPrompt?: string | undefined;
|
|
130
130
|
prePromptReplace?: string | undefined;
|
|
131
131
|
postPromptReplace?: string | undefined;
|
|
132
132
|
prePromptAppend?: string | undefined;
|
|
133
|
-
|
|
133
|
+
postPromptPrepend?: string | undefined;
|
|
134
134
|
};
|
|
135
135
|
debug?: boolean | undefined;
|
|
136
136
|
globby?: string | undefined;
|
|
@@ -153,14 +153,14 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
153
153
|
llm: {
|
|
154
154
|
choice: "gemini" | "anthropic" | "huggingface";
|
|
155
155
|
model: string | null;
|
|
156
|
-
prePrompt?: string | undefined;
|
|
157
|
-
postPrompt?: string | undefined;
|
|
158
156
|
temperature?: number | undefined;
|
|
159
157
|
sleep?: number | undefined;
|
|
158
|
+
prePrompt?: string | undefined;
|
|
159
|
+
postPrompt?: string | undefined;
|
|
160
160
|
prePromptReplace?: string | undefined;
|
|
161
161
|
postPromptReplace?: string | undefined;
|
|
162
162
|
prePromptAppend?: string | undefined;
|
|
163
|
-
|
|
163
|
+
postPromptPrepend?: string | undefined;
|
|
164
164
|
};
|
|
165
165
|
debug?: boolean | undefined;
|
|
166
166
|
globby?: string | undefined;
|
|
@@ -183,14 +183,14 @@ declare const configSchema: z.ZodEffects<z.ZodObject<{
|
|
|
183
183
|
llm: {
|
|
184
184
|
choice: "gemini" | "anthropic" | "huggingface";
|
|
185
185
|
model: string | null;
|
|
186
|
-
prePrompt?: string | undefined;
|
|
187
|
-
postPrompt?: string | undefined;
|
|
188
186
|
temperature?: number | undefined;
|
|
189
187
|
sleep?: number | undefined;
|
|
188
|
+
prePrompt?: string | undefined;
|
|
189
|
+
postPrompt?: string | undefined;
|
|
190
190
|
prePromptReplace?: string | undefined;
|
|
191
191
|
postPromptReplace?: string | undefined;
|
|
192
192
|
prePromptAppend?: string | undefined;
|
|
193
|
-
|
|
193
|
+
postPromptPrepend?: string | undefined;
|
|
194
194
|
};
|
|
195
195
|
debug?: boolean | undefined;
|
|
196
196
|
globby?: string | undefined;
|
|
@@ -25,12 +25,12 @@ var configSchema = z.object({
|
|
|
25
25
|
model: z.string().nullable(),
|
|
26
26
|
temperature: z.number().optional(),
|
|
27
27
|
sleep: z.number().optional(),
|
|
28
|
-
prePrompt: z.string().optional(),
|
|
29
|
-
postPrompt: z.string().optional(),
|
|
28
|
+
prePrompt: z.string().max(128).optional(),
|
|
29
|
+
postPrompt: z.string().max(128).optional(),
|
|
30
30
|
prePromptReplace: z.string().optional(),
|
|
31
31
|
postPromptReplace: z.string().optional(),
|
|
32
32
|
prePromptAppend: z.string().optional(),
|
|
33
|
-
|
|
33
|
+
postPromptPrepend: z.string().optional()
|
|
34
34
|
}),
|
|
35
35
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
36
36
|
}).refine(
|
package/dist/types/index.d.mts
CHANGED
|
@@ -12,7 +12,7 @@ type CommitResponse = string | {
|
|
|
12
12
|
translation: GringowTranslation;
|
|
13
13
|
original: string;
|
|
14
14
|
};
|
|
15
|
-
type Asker<T> = (message: string) => Promise<T>;
|
|
15
|
+
type Asker<T> = (message: string, prePrompt: string, postPrompt: string) => Promise<T>;
|
|
16
16
|
type Commiter<T> = (response: T) => CommitResponse;
|
|
17
17
|
type Parser = (unparsed: CommitResponse) => GringowCacheItem;
|
|
18
18
|
type LLMOptions = z.infer<typeof llmOptionsSchema>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gringow/gringow",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,14 +21,17 @@
|
|
|
21
21
|
"import": "./dist/browser.mjs"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"author": "Renato Gaspar <
|
|
24
|
+
"author": "Renato Gaspar <rntgspr@gmail.com>",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
25
29
|
"contributors": [
|
|
26
30
|
{
|
|
27
31
|
"name": "Renato Gaspar",
|
|
28
|
-
"email": "
|
|
32
|
+
"email": "rntgspr@gmail.com"
|
|
29
33
|
}
|
|
30
34
|
],
|
|
31
|
-
"license": "MIT",
|
|
32
35
|
"description": "AI-powered translation library for template strings using multiple LLM providers",
|
|
33
36
|
"files": [
|
|
34
37
|
"dist/",
|
|
File without changes
|