solid-translate 1.5.0 → 1.6.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/README.md +18 -1
- package/dist/cli.js +24 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -406,7 +406,7 @@ on every pull request.
|
|
|
406
406
|
"sourceLocale": "en",
|
|
407
407
|
"targetLocales": ["es", "fr", "de"],
|
|
408
408
|
"localesDir": "./src/locales",
|
|
409
|
-
"provider": "openrouter",
|
|
409
|
+
"provider": "openrouter", // openai | openrouter | anthropic | google | openai-compatible
|
|
410
410
|
"model": "openai/gpt-4o-mini",
|
|
411
411
|
"batchSize": 50,
|
|
412
412
|
"maxAttempts": 3,
|
|
@@ -425,6 +425,23 @@ on every pull request.
|
|
|
425
425
|
}
|
|
426
426
|
```
|
|
427
427
|
|
|
428
|
+
### Any OpenAI-compatible host
|
|
429
|
+
|
|
430
|
+
Point the CLI at a self-hosted gateway or an inference endpoint that speaks the
|
|
431
|
+
OpenAI chat-completions API:
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"provider": "openai-compatible",
|
|
436
|
+
"baseURL": "https://api.heyditto.ai/v1",
|
|
437
|
+
"apiKeyEnv": "DITTO_TRANSLATE_KEY",
|
|
438
|
+
"model": "translate"
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
`apiKeyEnv` names the environment variable that holds the key (default
|
|
443
|
+
`OPENAI_COMPATIBLE_API_KEY`). The `model` is whatever id the host accepts.
|
|
444
|
+
|
|
428
445
|
### Reliability: retries, splitting and batch size
|
|
429
446
|
|
|
430
447
|
Every batch is retried with exponential backoff (default `maxAttempts: 3`), and each
|
package/dist/cli.js
CHANGED
|
@@ -15318,10 +15318,30 @@ async function loadConfig() {
|
|
|
15318
15318
|
);
|
|
15319
15319
|
process.exit(1);
|
|
15320
15320
|
}
|
|
15321
|
+
function resolveOpenAICompatible(config) {
|
|
15322
|
+
const baseURL = (config.baseURL || "").trim().replace(/\/+$/, "");
|
|
15323
|
+
if (!baseURL) {
|
|
15324
|
+
throw new Error(
|
|
15325
|
+
'provider "openai-compatible" requires "baseURL" in the config (e.g. "https://api.heyditto.ai/v1")'
|
|
15326
|
+
);
|
|
15327
|
+
}
|
|
15328
|
+
return { baseURL, apiKeyEnv: config.apiKeyEnv || "OPENAI_COMPATIBLE_API_KEY" };
|
|
15329
|
+
}
|
|
15321
15330
|
async function createModel(config) {
|
|
15322
15331
|
const provider = config.provider || "openai";
|
|
15323
15332
|
const modelId = config.model || "gpt-4o-mini";
|
|
15324
15333
|
try {
|
|
15334
|
+
if (provider === "openai-compatible") {
|
|
15335
|
+
const { baseURL, apiKeyEnv } = resolveOpenAICompatible(config);
|
|
15336
|
+
const apiKey = process.env[apiKeyEnv];
|
|
15337
|
+
if (!apiKey) {
|
|
15338
|
+
console.error(`Missing ${apiKeyEnv} for provider "openai-compatible" (${baseURL}).`);
|
|
15339
|
+
process.exit(1);
|
|
15340
|
+
}
|
|
15341
|
+
const { createOpenAI } = await import("./dist-ZA6JWKFH.js");
|
|
15342
|
+
const compat = createOpenAI({ baseURL, apiKey, compatibility: "compatible" });
|
|
15343
|
+
return compat.chat(modelId);
|
|
15344
|
+
}
|
|
15325
15345
|
if (provider === "openai" || provider === "openrouter") {
|
|
15326
15346
|
const { createOpenAI } = await import("./dist-ZA6JWKFH.js");
|
|
15327
15347
|
if (provider === "openrouter") {
|
|
@@ -15351,7 +15371,7 @@ async function createModel(config) {
|
|
|
15351
15371
|
return google(modelId);
|
|
15352
15372
|
}
|
|
15353
15373
|
console.error(`Unknown provider: ${provider}`);
|
|
15354
|
-
console.error("Supported: openai, openrouter, anthropic, google");
|
|
15374
|
+
console.error("Supported: openai, openrouter, anthropic, google, openai-compatible");
|
|
15355
15375
|
process.exit(1);
|
|
15356
15376
|
} catch (err) {
|
|
15357
15377
|
console.error(
|
|
@@ -15714,3 +15734,6 @@ main().catch((err) => {
|
|
|
15714
15734
|
console.error(err);
|
|
15715
15735
|
process.exit(1);
|
|
15716
15736
|
});
|
|
15737
|
+
export {
|
|
15738
|
+
resolveOpenAICompatible
|
|
15739
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-translate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "AI-powered build-time translations for SolidJS. Full i18n with <T>, <Var>, <Num>, <Currency>, <Plural>, <DateTime>, locale detection, and a CLI — all BYOK.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|