mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 09:41:20 -08:00
Update OpenAI translation engine and increase max
tokens limit
This commit is contained in:
1 parent
7df74e227a
commit
69197312cc
1 file changed
+3
-3
@@ -47,10 +47,10 @@ function splitMarkdown(text, maxChars) {
|
|||||||
const translateContent = async (content, targetLanguage, openAIKey) => {
|
const translateContent = async (content, targetLanguage, openAIKey) => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
const response = await axios.post(
|
||||||
'https://api.openai.com/v1/engines/gpt-3.5-turbo/completions',
|
'https://api.openai.com/v1/engines/gpt-4-1106-preview/completions',
|
||||||
{
|
{
|
||||||
prompt: `Translate the following text to ${targetLanguage}:\n\n${content}`,
|
prompt: `Translate the following text to ${targetLanguage}:\n\n${content}`,
|
||||||
max_tokens: 1024,
|
max_tokens: 2048,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
@@ -95,7 +95,7 @@ const translateMarkdownFiles = async (filePaths, targetLanguage, openAIKey, maxC
|
|||||||
}
|
}
|
||||||
const mdsPaths = glob.sync(path.resolve(enPath, '**/*.md'));
|
const mdsPaths = glob.sync(path.resolve(enPath, '**/*.md'));
|
||||||
const openAIKey = process.env.OPENAI_KEY;
|
const openAIKey = process.env.OPENAI_KEY;
|
||||||
const maxCharsPerRequest = 1000;
|
const maxCharsPerRequest = 2000;
|
||||||
if (openAIKey) {
|
if (openAIKey) {
|
||||||
await translateMarkdownFiles(mdsPaths, 'English', openAIKey, maxCharsPerRequest);
|
await translateMarkdownFiles(mdsPaths, 'English', openAIKey, maxCharsPerRequest);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user