fix: AI language code
This commit is contained in:
@@ -99,7 +99,7 @@ async (args) => {
|
||||
{
|
||||
role: "user",
|
||||
content: JSON.stringify({
|
||||
targetLanguage: args.to,
|
||||
targetLanguage: args.toLang,
|
||||
segments: args.texts.map((text, id) => ({ id, text })),
|
||||
glossary: {},
|
||||
}),
|
||||
@@ -132,7 +132,7 @@ async (args) => {
|
||||
{
|
||||
role: "user",
|
||||
content: JSON.stringify({
|
||||
targetLanguage: args.to,
|
||||
targetLanguage: args.toLang,
|
||||
segments: args.texts.map((text, id) => ({ id, text })),
|
||||
glossary: {},
|
||||
}),
|
||||
|
||||
@@ -74,12 +74,13 @@ const genUserPrompt = ({
|
||||
glossary = {},
|
||||
from,
|
||||
to,
|
||||
toLang,
|
||||
texts,
|
||||
docInfo,
|
||||
}) => {
|
||||
if (useBatchFetch) {
|
||||
return JSON.stringify({
|
||||
targetLanguage: to,
|
||||
targetLanguage: toLang,
|
||||
title: docInfo.title,
|
||||
description: docInfo.description,
|
||||
segments: texts.map((text, i) => ({ id: i, text })),
|
||||
@@ -557,8 +558,8 @@ const genCloudflareAI = ({ texts, from, to, url, key }) => {
|
||||
return { url, body, headers };
|
||||
};
|
||||
|
||||
const genCustom = ({ texts, from, to, url, key }) => {
|
||||
const body = { texts, from, to };
|
||||
const genCustom = ({ texts, fromLang, toLang, url, key }) => {
|
||||
const body = { texts, from: fromLang, to: toLang };
|
||||
const headers = {
|
||||
"Content-type": "application/json",
|
||||
Authorization: `Bearer ${key}`,
|
||||
@@ -638,6 +639,8 @@ export const genTransReq = async ({ reqHook, ...args }) => {
|
||||
useBatchFetch,
|
||||
from,
|
||||
to,
|
||||
fromLang,
|
||||
toLang,
|
||||
texts,
|
||||
docInfo,
|
||||
glossary,
|
||||
@@ -667,6 +670,8 @@ export const genTransReq = async ({ reqHook, ...args }) => {
|
||||
useBatchFetch,
|
||||
from,
|
||||
to,
|
||||
fromLang,
|
||||
toLang,
|
||||
texts,
|
||||
docInfo,
|
||||
glossary,
|
||||
|
||||
@@ -312,14 +312,14 @@ export const OPT_LANGS_TO_SPEC = {
|
||||
["id", "id"],
|
||||
["vi", "vi"],
|
||||
]),
|
||||
[OPT_TRANS_OPENAI]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_GEMINI]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_GEMINI_2]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_CLAUDE]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_OLLAMA]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_OPENROUTER]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_CLOUDFLAREAI]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_CUSTOMIZE]: OPT_LANGS_SPEC_DEFAULT,
|
||||
[OPT_TRANS_OPENAI]: OPT_LANGS_SPEC_NAME,
|
||||
[OPT_TRANS_GEMINI]: OPT_LANGS_SPEC_NAME,
|
||||
[OPT_TRANS_GEMINI_2]: OPT_LANGS_SPEC_NAME,
|
||||
[OPT_TRANS_CLAUDE]: OPT_LANGS_SPEC_NAME,
|
||||
[OPT_TRANS_OLLAMA]: OPT_LANGS_SPEC_NAME,
|
||||
[OPT_TRANS_OPENROUTER]: OPT_LANGS_SPEC_NAME,
|
||||
[OPT_TRANS_CLOUDFLAREAI]: OPT_LANGS_SPEC_NAME,
|
||||
[OPT_TRANS_CUSTOMIZE]: OPT_LANGS_SPEC_NAME,
|
||||
};
|
||||
|
||||
const specToCode = (m) =>
|
||||
@@ -342,7 +342,7 @@ Object.entries(OPT_LANGS_TO_SPEC).forEach(([t, m]) => {
|
||||
});
|
||||
|
||||
export const defaultNobatchPrompt = `You are a professional, authentic machine translation engine.`;
|
||||
export const defaultNobatchUserPrompt = `Translate the following source text from ${INPUT_PLACE_FROM} to ${INPUT_PLACE_TO}. Output translation directly without any additional text.\n\nSource Text: ${INPUT_PLACE_TEXT}\n\nTranslated Text:`;
|
||||
export const defaultNobatchUserPrompt = `Translate the following source text to ${INPUT_PLACE_TO}. Output translation directly without any additional text.\n\nSource Text: ${INPUT_PLACE_TEXT}\n\nTranslated Text:`;
|
||||
|
||||
export const defaultSystemPrompt = `Act as a translation API. Output a single raw JSON object only. No extra text or fences.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user