Rename apiCustomParams to customBody

This commit is contained in:
FlyLoongZ
2025-08-11 16:03:30 +08:00
parent be6e34ba52
commit e1f902c203
4 changed files with 26 additions and 26 deletions

View File

@@ -240,7 +240,7 @@ const genOpenAI = ({
model, model,
temperature, temperature,
maxTokens, maxTokens,
apiCustomParams, customBody,
}) => { }) => {
// 兼容历史上作为systemPrompt的prompt如果prompt中不包含带翻译文本则添加文本到prompt末尾 // 兼容历史上作为systemPrompt的prompt如果prompt中不包含带翻译文本则添加文本到prompt末尾
// if (!prompt.includes(INPUT_PLACE_TEXT)) { // if (!prompt.includes(INPUT_PLACE_TEXT)) {
@@ -255,7 +255,7 @@ const genOpenAI = ({
.replaceAll(INPUT_PLACE_TO, to) .replaceAll(INPUT_PLACE_TO, to)
.replaceAll(INPUT_PLACE_TEXT, text); .replaceAll(INPUT_PLACE_TEXT, text);
apiCustomParams = JSON.parse("{" + apiCustomParams + "}"); customBody = JSON.parse("{" + customBody + "}");
const data = { const data = {
model, model,
@@ -271,7 +271,7 @@ const genOpenAI = ({
], ],
temperature, temperature,
max_completion_tokens: maxTokens, max_completion_tokens: maxTokens,
...apiCustomParams, ...customBody,
}; };
const init = { const init = {
@@ -298,7 +298,7 @@ const genGemini = ({
model, model,
temperature, temperature,
maxTokens, maxTokens,
apiCustomParams, customBody,
}) => { }) => {
url = url url = url
.replaceAll(INPUT_PLACE_MODEL, model) .replaceAll(INPUT_PLACE_MODEL, model)
@@ -312,7 +312,7 @@ const genGemini = ({
.replaceAll(INPUT_PLACE_TO, to) .replaceAll(INPUT_PLACE_TO, to)
.replaceAll(INPUT_PLACE_TEXT, text); .replaceAll(INPUT_PLACE_TEXT, text);
apiCustomParams = JSON.parse("{" + apiCustomParams + "}"); customBody = JSON.parse("{" + customBody + "}");
const data = { const data = {
system_instruction: { system_instruction: {
@@ -332,7 +332,7 @@ const genGemini = ({
// topP: 0.8, // topP: 0.8,
// topK: 10, // topK: 10,
}, },
...apiCustomParams, ...customBody,
}; };
const init = { const init = {
@@ -357,7 +357,7 @@ const genGemini2 = ({
model, model,
temperature, temperature,
maxTokens, maxTokens,
apiCustomParams, customBody,
}) => { }) => {
systemPrompt = systemPrompt systemPrompt = systemPrompt
.replaceAll(INPUT_PLACE_FROM, from) .replaceAll(INPUT_PLACE_FROM, from)
@@ -368,7 +368,7 @@ const genGemini2 = ({
.replaceAll(INPUT_PLACE_TO, to) .replaceAll(INPUT_PLACE_TO, to)
.replaceAll(INPUT_PLACE_TEXT, text); .replaceAll(INPUT_PLACE_TEXT, text);
apiCustomParams = JSON.parse("{" + apiCustomParams + "}"); customBody = JSON.parse("{" + customBody + "}");
const data = { const data = {
model, model,
@@ -384,7 +384,7 @@ const genGemini2 = ({
], ],
temperature, temperature,
max_tokens: maxTokens, max_tokens: maxTokens,
...apiCustomParams, ...customBody,
}; };
const init = { const init = {
@@ -410,7 +410,7 @@ const genClaude = ({
model, model,
temperature, temperature,
maxTokens, maxTokens,
apiCustomParams, customBody,
}) => { }) => {
systemPrompt = systemPrompt systemPrompt = systemPrompt
.replaceAll(INPUT_PLACE_FROM, from) .replaceAll(INPUT_PLACE_FROM, from)
@@ -421,7 +421,7 @@ const genClaude = ({
.replaceAll(INPUT_PLACE_TO, to) .replaceAll(INPUT_PLACE_TO, to)
.replaceAll(INPUT_PLACE_TEXT, text); .replaceAll(INPUT_PLACE_TEXT, text);
apiCustomParams = JSON.parse("{" + apiCustomParams + "}"); customBody = JSON.parse("{" + customBody + "}");
const data = { const data = {
model, model,
@@ -434,7 +434,7 @@ const genClaude = ({
], ],
temperature, temperature,
max_tokens: maxTokens, max_tokens: maxTokens,
...apiCustomParams, ...customBody,
}; };
const init = { const init = {
@@ -460,7 +460,7 @@ const genOllama = ({
systemPrompt, systemPrompt,
userPrompt, userPrompt,
model, model,
apiCustomParams, customBody,
}) => { }) => {
systemPrompt = systemPrompt systemPrompt = systemPrompt
.replaceAll(INPUT_PLACE_FROM, from) .replaceAll(INPUT_PLACE_FROM, from)
@@ -471,7 +471,7 @@ const genOllama = ({
.replaceAll(INPUT_PLACE_TO, to) .replaceAll(INPUT_PLACE_TO, to)
.replaceAll(INPUT_PLACE_TEXT, text); .replaceAll(INPUT_PLACE_TEXT, text);
apiCustomParams = JSON.parse("{" + apiCustomParams + "}"); customBody = JSON.parse("{" + customBody + "}");
const data = { const data = {
model, model,
@@ -479,7 +479,7 @@ const genOllama = ({
prompt: userPrompt, prompt: userPrompt,
think: think, think: think,
stream: false, stream: false,
...apiCustomParams, ...customBody,
}; };
const init = { const init = {

View File

@@ -228,11 +228,11 @@ export const I18N = {
zh: `请求超时时间 (5000-30000ms)`, zh: `请求超时时间 (5000-30000ms)`,
en: `Request Timeout Time (5000-30000ms)`, en: `Request Timeout Time (5000-30000ms)`,
}, },
api_custom_params: { custom_body: {
zh: `API自定义参数`, zh: `自定义Body参数`,
en: `API Custom Params`, en: `API Custom Params`,
}, },
api_custom_params_help: { custom_body_help: {
zh: `使用JSON格式例如 "top_p": 0.7`, zh: `使用JSON格式例如 "top_p": 0.7`,
en: `Use JSON format, for example "top_p": 0.7`, en: `Use JSON format, for example "top_p": 0.7`,
}, },

View File

@@ -563,7 +563,7 @@ const defaultOpenaiApi = {
model: "gpt-4", model: "gpt-4",
systemPrompt: `You are a professional, authentic machine translation engine.`, systemPrompt: `You are a professional, authentic machine translation engine.`,
userPrompt: `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:`, userPrompt: `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:`,
apiCustomParams: "", customBody: "",
temperature: 0, temperature: 0,
maxTokens: 256, maxTokens: 256,
fetchLimit: 1, fetchLimit: 1,
@@ -578,7 +578,7 @@ const defaultOllamaApi = {
model: "llama3.1", model: "llama3.1",
systemPrompt: `You are a professional, authentic machine translation engine.`, systemPrompt: `You are a professional, authentic machine translation engine.`,
userPrompt: `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:`, userPrompt: `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:`,
apiCustomParams: "", customBody: "",
think: false, think: false,
thinkIgnore: `qwen3,deepseek-r1`, thinkIgnore: `qwen3,deepseek-r1`,
fetchLimit: 1, fetchLimit: 1,
@@ -679,7 +679,7 @@ export const DEFAULT_TRANS_APIS = {
model: "gemini-2.5-flash", model: "gemini-2.5-flash",
systemPrompt: `You are a professional, authentic machine translation engine.`, systemPrompt: `You are a professional, authentic machine translation engine.`,
userPrompt: `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:`, userPrompt: `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:`,
apiCustomParams: "", customBody: "",
temperature: 0, temperature: 0,
maxTokens: 2048, maxTokens: 2048,
fetchLimit: 1, fetchLimit: 1,
@@ -694,7 +694,7 @@ export const DEFAULT_TRANS_APIS = {
model: "gemini-2.0-flash", model: "gemini-2.0-flash",
systemPrompt: `You are a professional, authentic machine translation engine.`, systemPrompt: `You are a professional, authentic machine translation engine.`,
userPrompt: `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:`, userPrompt: `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:`,
apiCustomParams: "", customBody: "",
temperature: 0, temperature: 0,
maxTokens: 2048, maxTokens: 2048,
fetchLimit: 1, fetchLimit: 1,
@@ -709,7 +709,7 @@ export const DEFAULT_TRANS_APIS = {
model: "claude-3-haiku-20240307", model: "claude-3-haiku-20240307",
systemPrompt: `You are a professional, authentic machine translation engine.`, systemPrompt: `You are a professional, authentic machine translation engine.`,
userPrompt: `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:`, userPrompt: `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:`,
apiCustomParams: "", customBody: "",
temperature: 0, temperature: 0,
maxTokens: 1024, maxTokens: 1024,
fetchLimit: 1, fetchLimit: 1,

View File

@@ -125,7 +125,7 @@ function ApiFields({ translator, api, updateApi, resetApi }) {
model = "", model = "",
systemPrompt = "", systemPrompt = "",
userPrompt = "", userPrompt = "",
apiCustomParams = "", customBody = "",
think = false, think = false,
thinkIgnore = "", thinkIgnore = "",
fetchLimit = DEFAULT_FETCH_LIMIT, fetchLimit = DEFAULT_FETCH_LIMIT,
@@ -278,8 +278,8 @@ function ApiFields({ translator, api, updateApi, resetApi }) {
<TextField <TextField
size="small" size="small"
label={i18n("api_custom_params")} label={i18n("api_custom_params")}
name="apiCustomParams" name="customBody"
value={apiCustomParams} value={customBody}
onChange={handleChange} onChange={handleChange}
multiline multiline
maxRows={10} maxRows={10}