@gringow/gringow 0.1.4 → 0.2.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 +6 -8
- package/dist/config.mjs +30 -20
- package/dist/config.test.mjs +37 -25
- package/dist/constants/default-config.mjs +3 -3
- package/dist/data/check-cache.mjs +31 -63
- package/dist/data/clear-cache.mjs +30 -20
- package/dist/data/create-cache-dir.mjs +30 -20
- package/dist/data/delete-cache-item.mjs +30 -20
- package/dist/data/get-cache.mjs +30 -20
- package/dist/data/get-or-create-cache.mjs +30 -20
- package/dist/data/save-cache.mjs +30 -20
- package/dist/data/write-cache-to-disk.mjs +30 -20
- package/dist/gringow.mjs +82 -491
- package/dist/index.mjs +82 -491
- package/dist/io/ask-llm.d.mts +3 -1
- package/dist/io/ask-llm.mjs +75 -449
- package/dist/schemas/config.shcema.d.mts +35 -47
- package/dist/schemas/config.shcema.mjs +25 -15
- package/dist/types/index.d.mts +3 -25
- package/gringow.config.js.example +2 -4
- package/gringow.config.json.example +4 -2
- package/package.json +2 -5
- package/dist/io/anthropic/ask.d.mts +0 -11
- package/dist/io/anthropic/ask.mjs +0 -192
- package/dist/io/anthropic/commit-response.d.mts +0 -21
- package/dist/io/anthropic/commit-response.mjs +0 -10
- package/dist/io/anthropic/index.d.mts +0 -14
- package/dist/io/anthropic/index.mjs +0 -210
- package/dist/io/anthropic/parse.d.mts +0 -20
- package/dist/io/anthropic/parse.mjs +0 -10
- package/dist/io/gemini/ask.d.mts +0 -11
- package/dist/io/gemini/ask.mjs +0 -234
- package/dist/io/gemini/commit-response.d.mts +0 -11
- package/dist/io/gemini/commit-response.mjs +0 -7
- package/dist/io/gemini/index.d.mts +0 -14
- package/dist/io/gemini/index.mjs +0 -250
- package/dist/io/gemini/parse.d.mts +0 -20
- package/dist/io/gemini/parse.mjs +0 -11
- package/dist/io/huggingface/ask.d.mts +0 -13
- package/dist/io/huggingface/ask.mjs +0 -407
- package/dist/io/huggingface/commit-response.d.mts +0 -39
- package/dist/io/huggingface/commit-response.mjs +0 -14
- package/dist/io/huggingface/index.d.mts +0 -13
- package/dist/io/huggingface/index.mjs +0 -428
- package/dist/io/huggingface/languages-map.d.mts +0 -191
- package/dist/io/huggingface/languages-map.mjs +0 -187
- package/dist/io/huggingface/parse.d.mts +0 -20
- package/dist/io/huggingface/parse.mjs +0 -9
|
@@ -19,20 +19,34 @@ var defaultConfig = {
|
|
|
19
19
|
prefix: "grw",
|
|
20
20
|
write: true
|
|
21
21
|
},
|
|
22
|
-
keys: {},
|
|
23
22
|
sourceLanguage: "en-US",
|
|
24
23
|
defaultLanguage: "pt-BR",
|
|
25
24
|
languages: ["pt-BR", "fr-CA"],
|
|
26
25
|
llm: {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
provider: "openai",
|
|
27
|
+
apiKey: void 0,
|
|
28
|
+
model: "gpt-4o-mini",
|
|
29
29
|
temperature: 1,
|
|
30
30
|
sleep: 0
|
|
31
31
|
},
|
|
32
32
|
globby: "./src/**/*.{js,jsx,ts,tsx}"
|
|
33
33
|
};
|
|
34
34
|
var languageSchema = z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?$/);
|
|
35
|
-
var
|
|
35
|
+
var llmProviderSchema = z.enum([
|
|
36
|
+
"anthropic",
|
|
37
|
+
"gemini",
|
|
38
|
+
"openai",
|
|
39
|
+
"groq",
|
|
40
|
+
"mistral",
|
|
41
|
+
"ollama",
|
|
42
|
+
"xai",
|
|
43
|
+
"deepseek",
|
|
44
|
+
"openrouter",
|
|
45
|
+
"cerebras",
|
|
46
|
+
"lmstudio",
|
|
47
|
+
"azure",
|
|
48
|
+
"meta"
|
|
49
|
+
]);
|
|
36
50
|
var configSchema = z.object({
|
|
37
51
|
debug: z.boolean().optional(),
|
|
38
52
|
log: z.object({
|
|
@@ -44,15 +58,13 @@ var configSchema = z.object({
|
|
|
44
58
|
prefix: z.string(),
|
|
45
59
|
write: z.boolean().optional()
|
|
46
60
|
}),
|
|
47
|
-
keys: z.object({
|
|
48
|
-
anthropicApiKey: z.string().optional(),
|
|
49
|
-
geminiApiKey: z.string().optional()
|
|
50
|
-
}),
|
|
51
61
|
sourceLanguage: languageSchema,
|
|
52
62
|
defaultLanguage: languageSchema,
|
|
53
63
|
languages: z.array(languageSchema),
|
|
54
64
|
llm: z.object({
|
|
55
|
-
|
|
65
|
+
provider: llmProviderSchema,
|
|
66
|
+
apiKey: z.string().optional(),
|
|
67
|
+
baseURL: z.string().optional(),
|
|
56
68
|
model: z.string().nullable(),
|
|
57
69
|
temperature: z.number().optional(),
|
|
58
70
|
sleep: z.number().optional(),
|
|
@@ -66,17 +78,15 @@ var configSchema = z.object({
|
|
|
66
78
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
67
79
|
}).refine(
|
|
68
80
|
(data) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (data.llm.choice === "anthropic" && !data.keys.anthropicApiKey) {
|
|
73
|
-
return false;
|
|
81
|
+
const noApiKeyRequired = ["ollama", "lmstudio"];
|
|
82
|
+
if (noApiKeyRequired.includes(data.llm.provider)) {
|
|
83
|
+
return true;
|
|
74
84
|
}
|
|
75
|
-
return
|
|
85
|
+
return !!data.llm.apiKey;
|
|
76
86
|
},
|
|
77
87
|
{
|
|
78
|
-
message: "The API key
|
|
79
|
-
path: ["
|
|
88
|
+
message: "The API key must be present in llm.apiKey for the chosen provider.",
|
|
89
|
+
path: ["llm", "apiKey"]
|
|
80
90
|
}
|
|
81
91
|
);
|
|
82
92
|
|
|
@@ -112,7 +122,7 @@ Your task is to translate a given text and output **only one valid JSON object**
|
|
|
112
122
|
|
|
113
123
|
Follow these rules strictly:
|
|
114
124
|
|
|
115
|
-
1. The original text is written in English.
|
|
125
|
+
1. The original text is written in English or Spanish.
|
|
116
126
|
2. You will receive additional user parameters under the variable 'extraInstructions'. These may specify tone, persona, style, context, or any relevant translation guideline.
|
|
117
127
|
- Examples: \u201Ctranslate as if you were a Shakespearean narrator\u201D or \u201Cuse a formal business tone suitable for a corporate presentation.\u201D
|
|
118
128
|
- Apply these creatively but **without altering the meaning or punctuation** of the original text.
|
|
@@ -145,10 +155,10 @@ Translate the following text faithfully:
|
|
|
145
155
|
function defaultPostPrompt(_config) {
|
|
146
156
|
return "";
|
|
147
157
|
}
|
|
148
|
-
function prePrompt(config,
|
|
158
|
+
function prePrompt(config, prepend, replace) {
|
|
149
159
|
return [
|
|
150
160
|
// ...(append ? ['[SPECIFIC_INPUTS]', String(append), '[/SPECIFIC_INPUTS]'] : []),
|
|
151
|
-
replace ? String(replace) : defaultPrePrompt(config,
|
|
161
|
+
replace ? String(replace) : defaultPrePrompt(config, prepend)
|
|
152
162
|
].join(" ").trim();
|
|
153
163
|
}
|
|
154
164
|
function postPrompt(config, prepend, replace) {
|
package/dist/data/get-cache.mjs
CHANGED
|
@@ -19,20 +19,34 @@ var defaultConfig = {
|
|
|
19
19
|
prefix: "grw",
|
|
20
20
|
write: true
|
|
21
21
|
},
|
|
22
|
-
keys: {},
|
|
23
22
|
sourceLanguage: "en-US",
|
|
24
23
|
defaultLanguage: "pt-BR",
|
|
25
24
|
languages: ["pt-BR", "fr-CA"],
|
|
26
25
|
llm: {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
provider: "openai",
|
|
27
|
+
apiKey: void 0,
|
|
28
|
+
model: "gpt-4o-mini",
|
|
29
29
|
temperature: 1,
|
|
30
30
|
sleep: 0
|
|
31
31
|
},
|
|
32
32
|
globby: "./src/**/*.{js,jsx,ts,tsx}"
|
|
33
33
|
};
|
|
34
34
|
var languageSchema = z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?$/);
|
|
35
|
-
var
|
|
35
|
+
var llmProviderSchema = z.enum([
|
|
36
|
+
"anthropic",
|
|
37
|
+
"gemini",
|
|
38
|
+
"openai",
|
|
39
|
+
"groq",
|
|
40
|
+
"mistral",
|
|
41
|
+
"ollama",
|
|
42
|
+
"xai",
|
|
43
|
+
"deepseek",
|
|
44
|
+
"openrouter",
|
|
45
|
+
"cerebras",
|
|
46
|
+
"lmstudio",
|
|
47
|
+
"azure",
|
|
48
|
+
"meta"
|
|
49
|
+
]);
|
|
36
50
|
var configSchema = z.object({
|
|
37
51
|
debug: z.boolean().optional(),
|
|
38
52
|
log: z.object({
|
|
@@ -44,15 +58,13 @@ var configSchema = z.object({
|
|
|
44
58
|
prefix: z.string(),
|
|
45
59
|
write: z.boolean().optional()
|
|
46
60
|
}),
|
|
47
|
-
keys: z.object({
|
|
48
|
-
anthropicApiKey: z.string().optional(),
|
|
49
|
-
geminiApiKey: z.string().optional()
|
|
50
|
-
}),
|
|
51
61
|
sourceLanguage: languageSchema,
|
|
52
62
|
defaultLanguage: languageSchema,
|
|
53
63
|
languages: z.array(languageSchema),
|
|
54
64
|
llm: z.object({
|
|
55
|
-
|
|
65
|
+
provider: llmProviderSchema,
|
|
66
|
+
apiKey: z.string().optional(),
|
|
67
|
+
baseURL: z.string().optional(),
|
|
56
68
|
model: z.string().nullable(),
|
|
57
69
|
temperature: z.number().optional(),
|
|
58
70
|
sleep: z.number().optional(),
|
|
@@ -66,17 +78,15 @@ var configSchema = z.object({
|
|
|
66
78
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
67
79
|
}).refine(
|
|
68
80
|
(data) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (data.llm.choice === "anthropic" && !data.keys.anthropicApiKey) {
|
|
73
|
-
return false;
|
|
81
|
+
const noApiKeyRequired = ["ollama", "lmstudio"];
|
|
82
|
+
if (noApiKeyRequired.includes(data.llm.provider)) {
|
|
83
|
+
return true;
|
|
74
84
|
}
|
|
75
|
-
return
|
|
85
|
+
return !!data.llm.apiKey;
|
|
76
86
|
},
|
|
77
87
|
{
|
|
78
|
-
message: "The API key
|
|
79
|
-
path: ["
|
|
88
|
+
message: "The API key must be present in llm.apiKey for the chosen provider.",
|
|
89
|
+
path: ["llm", "apiKey"]
|
|
80
90
|
}
|
|
81
91
|
);
|
|
82
92
|
|
|
@@ -112,7 +122,7 @@ Your task is to translate a given text and output **only one valid JSON object**
|
|
|
112
122
|
|
|
113
123
|
Follow these rules strictly:
|
|
114
124
|
|
|
115
|
-
1. The original text is written in English.
|
|
125
|
+
1. The original text is written in English or Spanish.
|
|
116
126
|
2. You will receive additional user parameters under the variable 'extraInstructions'. These may specify tone, persona, style, context, or any relevant translation guideline.
|
|
117
127
|
- Examples: \u201Ctranslate as if you were a Shakespearean narrator\u201D or \u201Cuse a formal business tone suitable for a corporate presentation.\u201D
|
|
118
128
|
- Apply these creatively but **without altering the meaning or punctuation** of the original text.
|
|
@@ -145,10 +155,10 @@ Translate the following text faithfully:
|
|
|
145
155
|
function defaultPostPrompt(_config) {
|
|
146
156
|
return "";
|
|
147
157
|
}
|
|
148
|
-
function prePrompt(config,
|
|
158
|
+
function prePrompt(config, prepend, replace) {
|
|
149
159
|
return [
|
|
150
160
|
// ...(append ? ['[SPECIFIC_INPUTS]', String(append), '[/SPECIFIC_INPUTS]'] : []),
|
|
151
|
-
replace ? String(replace) : defaultPrePrompt(config,
|
|
161
|
+
replace ? String(replace) : defaultPrePrompt(config, prepend)
|
|
152
162
|
].join(" ").trim();
|
|
153
163
|
}
|
|
154
164
|
function postPrompt(config, prepend, replace) {
|
|
@@ -19,20 +19,34 @@ var defaultConfig = {
|
|
|
19
19
|
prefix: "grw",
|
|
20
20
|
write: true
|
|
21
21
|
},
|
|
22
|
-
keys: {},
|
|
23
22
|
sourceLanguage: "en-US",
|
|
24
23
|
defaultLanguage: "pt-BR",
|
|
25
24
|
languages: ["pt-BR", "fr-CA"],
|
|
26
25
|
llm: {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
provider: "openai",
|
|
27
|
+
apiKey: void 0,
|
|
28
|
+
model: "gpt-4o-mini",
|
|
29
29
|
temperature: 1,
|
|
30
30
|
sleep: 0
|
|
31
31
|
},
|
|
32
32
|
globby: "./src/**/*.{js,jsx,ts,tsx}"
|
|
33
33
|
};
|
|
34
34
|
var languageSchema = z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?$/);
|
|
35
|
-
var
|
|
35
|
+
var llmProviderSchema = z.enum([
|
|
36
|
+
"anthropic",
|
|
37
|
+
"gemini",
|
|
38
|
+
"openai",
|
|
39
|
+
"groq",
|
|
40
|
+
"mistral",
|
|
41
|
+
"ollama",
|
|
42
|
+
"xai",
|
|
43
|
+
"deepseek",
|
|
44
|
+
"openrouter",
|
|
45
|
+
"cerebras",
|
|
46
|
+
"lmstudio",
|
|
47
|
+
"azure",
|
|
48
|
+
"meta"
|
|
49
|
+
]);
|
|
36
50
|
var configSchema = z.object({
|
|
37
51
|
debug: z.boolean().optional(),
|
|
38
52
|
log: z.object({
|
|
@@ -44,15 +58,13 @@ var configSchema = z.object({
|
|
|
44
58
|
prefix: z.string(),
|
|
45
59
|
write: z.boolean().optional()
|
|
46
60
|
}),
|
|
47
|
-
keys: z.object({
|
|
48
|
-
anthropicApiKey: z.string().optional(),
|
|
49
|
-
geminiApiKey: z.string().optional()
|
|
50
|
-
}),
|
|
51
61
|
sourceLanguage: languageSchema,
|
|
52
62
|
defaultLanguage: languageSchema,
|
|
53
63
|
languages: z.array(languageSchema),
|
|
54
64
|
llm: z.object({
|
|
55
|
-
|
|
65
|
+
provider: llmProviderSchema,
|
|
66
|
+
apiKey: z.string().optional(),
|
|
67
|
+
baseURL: z.string().optional(),
|
|
56
68
|
model: z.string().nullable(),
|
|
57
69
|
temperature: z.number().optional(),
|
|
58
70
|
sleep: z.number().optional(),
|
|
@@ -66,17 +78,15 @@ var configSchema = z.object({
|
|
|
66
78
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
67
79
|
}).refine(
|
|
68
80
|
(data) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (data.llm.choice === "anthropic" && !data.keys.anthropicApiKey) {
|
|
73
|
-
return false;
|
|
81
|
+
const noApiKeyRequired = ["ollama", "lmstudio"];
|
|
82
|
+
if (noApiKeyRequired.includes(data.llm.provider)) {
|
|
83
|
+
return true;
|
|
74
84
|
}
|
|
75
|
-
return
|
|
85
|
+
return !!data.llm.apiKey;
|
|
76
86
|
},
|
|
77
87
|
{
|
|
78
|
-
message: "The API key
|
|
79
|
-
path: ["
|
|
88
|
+
message: "The API key must be present in llm.apiKey for the chosen provider.",
|
|
89
|
+
path: ["llm", "apiKey"]
|
|
80
90
|
}
|
|
81
91
|
);
|
|
82
92
|
|
|
@@ -112,7 +122,7 @@ Your task is to translate a given text and output **only one valid JSON object**
|
|
|
112
122
|
|
|
113
123
|
Follow these rules strictly:
|
|
114
124
|
|
|
115
|
-
1. The original text is written in English.
|
|
125
|
+
1. The original text is written in English or Spanish.
|
|
116
126
|
2. You will receive additional user parameters under the variable 'extraInstructions'. These may specify tone, persona, style, context, or any relevant translation guideline.
|
|
117
127
|
- Examples: \u201Ctranslate as if you were a Shakespearean narrator\u201D or \u201Cuse a formal business tone suitable for a corporate presentation.\u201D
|
|
118
128
|
- Apply these creatively but **without altering the meaning or punctuation** of the original text.
|
|
@@ -145,10 +155,10 @@ Translate the following text faithfully:
|
|
|
145
155
|
function defaultPostPrompt(_config) {
|
|
146
156
|
return "";
|
|
147
157
|
}
|
|
148
|
-
function prePrompt(config,
|
|
158
|
+
function prePrompt(config, prepend, replace) {
|
|
149
159
|
return [
|
|
150
160
|
// ...(append ? ['[SPECIFIC_INPUTS]', String(append), '[/SPECIFIC_INPUTS]'] : []),
|
|
151
|
-
replace ? String(replace) : defaultPrePrompt(config,
|
|
161
|
+
replace ? String(replace) : defaultPrePrompt(config, prepend)
|
|
152
162
|
].join(" ").trim();
|
|
153
163
|
}
|
|
154
164
|
function postPrompt(config, prepend, replace) {
|
package/dist/data/save-cache.mjs
CHANGED
|
@@ -19,20 +19,34 @@ var defaultConfig = {
|
|
|
19
19
|
prefix: "grw",
|
|
20
20
|
write: true
|
|
21
21
|
},
|
|
22
|
-
keys: {},
|
|
23
22
|
sourceLanguage: "en-US",
|
|
24
23
|
defaultLanguage: "pt-BR",
|
|
25
24
|
languages: ["pt-BR", "fr-CA"],
|
|
26
25
|
llm: {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
provider: "openai",
|
|
27
|
+
apiKey: void 0,
|
|
28
|
+
model: "gpt-4o-mini",
|
|
29
29
|
temperature: 1,
|
|
30
30
|
sleep: 0
|
|
31
31
|
},
|
|
32
32
|
globby: "./src/**/*.{js,jsx,ts,tsx}"
|
|
33
33
|
};
|
|
34
34
|
var languageSchema = z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?$/);
|
|
35
|
-
var
|
|
35
|
+
var llmProviderSchema = z.enum([
|
|
36
|
+
"anthropic",
|
|
37
|
+
"gemini",
|
|
38
|
+
"openai",
|
|
39
|
+
"groq",
|
|
40
|
+
"mistral",
|
|
41
|
+
"ollama",
|
|
42
|
+
"xai",
|
|
43
|
+
"deepseek",
|
|
44
|
+
"openrouter",
|
|
45
|
+
"cerebras",
|
|
46
|
+
"lmstudio",
|
|
47
|
+
"azure",
|
|
48
|
+
"meta"
|
|
49
|
+
]);
|
|
36
50
|
var configSchema = z.object({
|
|
37
51
|
debug: z.boolean().optional(),
|
|
38
52
|
log: z.object({
|
|
@@ -44,15 +58,13 @@ var configSchema = z.object({
|
|
|
44
58
|
prefix: z.string(),
|
|
45
59
|
write: z.boolean().optional()
|
|
46
60
|
}),
|
|
47
|
-
keys: z.object({
|
|
48
|
-
anthropicApiKey: z.string().optional(),
|
|
49
|
-
geminiApiKey: z.string().optional()
|
|
50
|
-
}),
|
|
51
61
|
sourceLanguage: languageSchema,
|
|
52
62
|
defaultLanguage: languageSchema,
|
|
53
63
|
languages: z.array(languageSchema),
|
|
54
64
|
llm: z.object({
|
|
55
|
-
|
|
65
|
+
provider: llmProviderSchema,
|
|
66
|
+
apiKey: z.string().optional(),
|
|
67
|
+
baseURL: z.string().optional(),
|
|
56
68
|
model: z.string().nullable(),
|
|
57
69
|
temperature: z.number().optional(),
|
|
58
70
|
sleep: z.number().optional(),
|
|
@@ -66,17 +78,15 @@ var configSchema = z.object({
|
|
|
66
78
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
67
79
|
}).refine(
|
|
68
80
|
(data) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (data.llm.choice === "anthropic" && !data.keys.anthropicApiKey) {
|
|
73
|
-
return false;
|
|
81
|
+
const noApiKeyRequired = ["ollama", "lmstudio"];
|
|
82
|
+
if (noApiKeyRequired.includes(data.llm.provider)) {
|
|
83
|
+
return true;
|
|
74
84
|
}
|
|
75
|
-
return
|
|
85
|
+
return !!data.llm.apiKey;
|
|
76
86
|
},
|
|
77
87
|
{
|
|
78
|
-
message: "The API key
|
|
79
|
-
path: ["
|
|
88
|
+
message: "The API key must be present in llm.apiKey for the chosen provider.",
|
|
89
|
+
path: ["llm", "apiKey"]
|
|
80
90
|
}
|
|
81
91
|
);
|
|
82
92
|
|
|
@@ -112,7 +122,7 @@ Your task is to translate a given text and output **only one valid JSON object**
|
|
|
112
122
|
|
|
113
123
|
Follow these rules strictly:
|
|
114
124
|
|
|
115
|
-
1. The original text is written in English.
|
|
125
|
+
1. The original text is written in English or Spanish.
|
|
116
126
|
2. You will receive additional user parameters under the variable 'extraInstructions'. These may specify tone, persona, style, context, or any relevant translation guideline.
|
|
117
127
|
- Examples: \u201Ctranslate as if you were a Shakespearean narrator\u201D or \u201Cuse a formal business tone suitable for a corporate presentation.\u201D
|
|
118
128
|
- Apply these creatively but **without altering the meaning or punctuation** of the original text.
|
|
@@ -145,10 +155,10 @@ Translate the following text faithfully:
|
|
|
145
155
|
function defaultPostPrompt(_config) {
|
|
146
156
|
return "";
|
|
147
157
|
}
|
|
148
|
-
function prePrompt(config,
|
|
158
|
+
function prePrompt(config, prepend, replace) {
|
|
149
159
|
return [
|
|
150
160
|
// ...(append ? ['[SPECIFIC_INPUTS]', String(append), '[/SPECIFIC_INPUTS]'] : []),
|
|
151
|
-
replace ? String(replace) : defaultPrePrompt(config,
|
|
161
|
+
replace ? String(replace) : defaultPrePrompt(config, prepend)
|
|
152
162
|
].join(" ").trim();
|
|
153
163
|
}
|
|
154
164
|
function postPrompt(config, prepend, replace) {
|
|
@@ -19,20 +19,34 @@ var defaultConfig = {
|
|
|
19
19
|
prefix: "grw",
|
|
20
20
|
write: true
|
|
21
21
|
},
|
|
22
|
-
keys: {},
|
|
23
22
|
sourceLanguage: "en-US",
|
|
24
23
|
defaultLanguage: "pt-BR",
|
|
25
24
|
languages: ["pt-BR", "fr-CA"],
|
|
26
25
|
llm: {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
provider: "openai",
|
|
27
|
+
apiKey: void 0,
|
|
28
|
+
model: "gpt-4o-mini",
|
|
29
29
|
temperature: 1,
|
|
30
30
|
sleep: 0
|
|
31
31
|
},
|
|
32
32
|
globby: "./src/**/*.{js,jsx,ts,tsx}"
|
|
33
33
|
};
|
|
34
34
|
var languageSchema = z.string().regex(/^[a-z]{2,3}(-[A-Z]{2})?$/);
|
|
35
|
-
var
|
|
35
|
+
var llmProviderSchema = z.enum([
|
|
36
|
+
"anthropic",
|
|
37
|
+
"gemini",
|
|
38
|
+
"openai",
|
|
39
|
+
"groq",
|
|
40
|
+
"mistral",
|
|
41
|
+
"ollama",
|
|
42
|
+
"xai",
|
|
43
|
+
"deepseek",
|
|
44
|
+
"openrouter",
|
|
45
|
+
"cerebras",
|
|
46
|
+
"lmstudio",
|
|
47
|
+
"azure",
|
|
48
|
+
"meta"
|
|
49
|
+
]);
|
|
36
50
|
var configSchema = z.object({
|
|
37
51
|
debug: z.boolean().optional(),
|
|
38
52
|
log: z.object({
|
|
@@ -44,15 +58,13 @@ var configSchema = z.object({
|
|
|
44
58
|
prefix: z.string(),
|
|
45
59
|
write: z.boolean().optional()
|
|
46
60
|
}),
|
|
47
|
-
keys: z.object({
|
|
48
|
-
anthropicApiKey: z.string().optional(),
|
|
49
|
-
geminiApiKey: z.string().optional()
|
|
50
|
-
}),
|
|
51
61
|
sourceLanguage: languageSchema,
|
|
52
62
|
defaultLanguage: languageSchema,
|
|
53
63
|
languages: z.array(languageSchema),
|
|
54
64
|
llm: z.object({
|
|
55
|
-
|
|
65
|
+
provider: llmProviderSchema,
|
|
66
|
+
apiKey: z.string().optional(),
|
|
67
|
+
baseURL: z.string().optional(),
|
|
56
68
|
model: z.string().nullable(),
|
|
57
69
|
temperature: z.number().optional(),
|
|
58
70
|
sleep: z.number().optional(),
|
|
@@ -66,17 +78,15 @@ var configSchema = z.object({
|
|
|
66
78
|
globby: z.string().regex(/^\.\/.*/).optional()
|
|
67
79
|
}).refine(
|
|
68
80
|
(data) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (data.llm.choice === "anthropic" && !data.keys.anthropicApiKey) {
|
|
73
|
-
return false;
|
|
81
|
+
const noApiKeyRequired = ["ollama", "lmstudio"];
|
|
82
|
+
if (noApiKeyRequired.includes(data.llm.provider)) {
|
|
83
|
+
return true;
|
|
74
84
|
}
|
|
75
|
-
return
|
|
85
|
+
return !!data.llm.apiKey;
|
|
76
86
|
},
|
|
77
87
|
{
|
|
78
|
-
message: "The API key
|
|
79
|
-
path: ["
|
|
88
|
+
message: "The API key must be present in llm.apiKey for the chosen provider.",
|
|
89
|
+
path: ["llm", "apiKey"]
|
|
80
90
|
}
|
|
81
91
|
);
|
|
82
92
|
|
|
@@ -112,7 +122,7 @@ Your task is to translate a given text and output **only one valid JSON object**
|
|
|
112
122
|
|
|
113
123
|
Follow these rules strictly:
|
|
114
124
|
|
|
115
|
-
1. The original text is written in English.
|
|
125
|
+
1. The original text is written in English or Spanish.
|
|
116
126
|
2. You will receive additional user parameters under the variable 'extraInstructions'. These may specify tone, persona, style, context, or any relevant translation guideline.
|
|
117
127
|
- Examples: \u201Ctranslate as if you were a Shakespearean narrator\u201D or \u201Cuse a formal business tone suitable for a corporate presentation.\u201D
|
|
118
128
|
- Apply these creatively but **without altering the meaning or punctuation** of the original text.
|
|
@@ -145,10 +155,10 @@ Translate the following text faithfully:
|
|
|
145
155
|
function defaultPostPrompt(_config) {
|
|
146
156
|
return "";
|
|
147
157
|
}
|
|
148
|
-
function prePrompt(config,
|
|
158
|
+
function prePrompt(config, prepend, replace) {
|
|
149
159
|
return [
|
|
150
160
|
// ...(append ? ['[SPECIFIC_INPUTS]', String(append), '[/SPECIFIC_INPUTS]'] : []),
|
|
151
|
-
replace ? String(replace) : defaultPrePrompt(config,
|
|
161
|
+
replace ? String(replace) : defaultPrePrompt(config, prepend)
|
|
152
162
|
].join(" ").trim();
|
|
153
163
|
}
|
|
154
164
|
function postPrompt(config, prepend, replace) {
|