fix: AI language code

This commit is contained in:
Gabe
2025-11-05 01:03:44 +08:00
parent a56fb6c8d6
commit 629bf9461a
3 changed files with 19 additions and 14 deletions

View File

@@ -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,