feat: Add AI API Custom Header

This commit is contained in:
FlyLoongZ
2025-08-11 16:28:23 +08:00
parent e1f902c203
commit a9b858ec6f
4 changed files with 42 additions and 3 deletions

View File

@@ -228,9 +228,17 @@ export const I18N = {
zh: `请求超时时间 (5000-30000ms)`,
en: `Request Timeout Time (5000-30000ms)`,
},
custom_header: {
zh: `自定义Header参数`,
en: `Custom Header Params`,
},
custom_header_help: {
zh: `使用JSON格式例如 "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:141.0) Gecko/20100101 Firefox/141.0"`,
en: `Use JSON format, for example "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:141.0) Gecko/20100101 Firefox/141.0"`,
},
custom_body: {
zh: `自定义Body参数`,
en: `API Custom Params`,
en: `Custom Body Params`,
},
custom_body_help: {
zh: `使用JSON格式例如 "top_p": 0.7`,

View File

@@ -563,6 +563,7 @@ const defaultOpenaiApi = {
model: "gpt-4",
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:`,
customHeader: "",
customBody: "",
temperature: 0,
maxTokens: 256,
@@ -578,6 +579,7 @@ const defaultOllamaApi = {
model: "llama3.1",
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:`,
customHeader: "",
customBody: "",
think: false,
thinkIgnore: `qwen3,deepseek-r1`,
@@ -679,6 +681,7 @@ export const DEFAULT_TRANS_APIS = {
model: "gemini-2.5-flash",
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:`,
customHeader: "",
customBody: "",
temperature: 0,
maxTokens: 2048,
@@ -694,6 +697,7 @@ export const DEFAULT_TRANS_APIS = {
model: "gemini-2.0-flash",
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:`,
customHeader: "",
customBody: "",
temperature: 0,
maxTokens: 2048,
@@ -709,6 +713,7 @@ export const DEFAULT_TRANS_APIS = {
model: "claude-3-haiku-20240307",
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:`,
customHeader: "",
customBody: "",
temperature: 0,
maxTokens: 1024,