transduck 0.6.1 → 0.6.2
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/cli.js
CHANGED
|
@@ -544,7 +544,7 @@ export async function runStats(opts) {
|
|
|
544
544
|
}
|
|
545
545
|
// CLI entry point
|
|
546
546
|
const program = new Command();
|
|
547
|
-
program.name('transduck').description('AI-native translation tool').version('0.6.
|
|
547
|
+
program.name('transduck').description('AI-native translation tool').version('0.6.2');
|
|
548
548
|
program.command('init')
|
|
549
549
|
.description('Initialize a new transduck project')
|
|
550
550
|
.action(async () => {
|
|
@@ -51,7 +51,14 @@ export async function translatePlural(one, other, sourceLang, targetLang, projec
|
|
|
51
51
|
model: config.backendModel,
|
|
52
52
|
messages,
|
|
53
53
|
temperature: 0.3,
|
|
54
|
+
response_format: { type: 'json_object' },
|
|
54
55
|
});
|
|
55
|
-
|
|
56
|
+
let raw = (response.choices[0].message.content || '').trim();
|
|
57
|
+
if (raw.startsWith('```')) {
|
|
58
|
+
raw = raw.split('\n').slice(1).join('\n').split('```')[0].trim();
|
|
59
|
+
}
|
|
60
|
+
if (!raw) {
|
|
61
|
+
throw new Error(`Empty response from OpenAI for plural translation: '${one}' / '${other}' → ${targetLang}`);
|
|
62
|
+
}
|
|
56
63
|
return JSON.parse(raw);
|
|
57
64
|
}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -661,7 +661,7 @@ export async function runStats(opts: StatsOptions): Promise<string> {
|
|
|
661
661
|
// CLI entry point
|
|
662
662
|
const program = new Command();
|
|
663
663
|
|
|
664
|
-
program.name('transduck').description('AI-native translation tool').version('0.6.
|
|
664
|
+
program.name('transduck').description('AI-native translation tool').version('0.6.2');
|
|
665
665
|
|
|
666
666
|
program.command('init')
|
|
667
667
|
.description('Initialize a new transduck project')
|
|
@@ -84,8 +84,15 @@ export async function translatePlural(
|
|
|
84
84
|
model: config.backendModel,
|
|
85
85
|
messages,
|
|
86
86
|
temperature: 0.3,
|
|
87
|
+
response_format: { type: 'json_object' },
|
|
87
88
|
});
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
let raw = (response.choices[0].message.content || '').trim();
|
|
91
|
+
if (raw.startsWith('```')) {
|
|
92
|
+
raw = raw.split('\n').slice(1).join('\n').split('```')[0].trim();
|
|
93
|
+
}
|
|
94
|
+
if (!raw) {
|
|
95
|
+
throw new Error(`Empty response from OpenAI for plural translation: '${one}' / '${other}' → ${targetLang}`);
|
|
96
|
+
}
|
|
90
97
|
return JSON.parse(raw);
|
|
91
98
|
}
|