@@ -192,25 +192,35 @@ const genOpenAI = ({
|
||||
to,
|
||||
url,
|
||||
key,
|
||||
systemPrompt,
|
||||
prompt,
|
||||
model,
|
||||
temperature,
|
||||
maxTokens,
|
||||
}) => {
|
||||
// 兼容历史上作为systemPrompt的prompt,如果prompt中不包含带翻译文本,则添加文本到prompt末尾
|
||||
if (!prompt.includes(INPUT_PLACE_TEXT)) {
|
||||
prompt += `\nSource Text: ${INPUT_PLACE_TEXT}`;
|
||||
}
|
||||
prompt = prompt
|
||||
.replaceAll(INPUT_PLACE_FROM, from)
|
||||
.replaceAll(INPUT_PLACE_TO, to);
|
||||
.replaceAll(INPUT_PLACE_TO, to)
|
||||
.replaceAll(INPUT_PLACE_TEXT, text);
|
||||
systemPrompt = systemPrompt
|
||||
.replaceAll(INPUT_PLACE_FROM, from)
|
||||
.replaceAll(INPUT_PLACE_TO, to)
|
||||
.replaceAll(INPUT_PLACE_TEXT, text);
|
||||
|
||||
const data = {
|
||||
model,
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: prompt,
|
||||
content: systemPrompt,
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: text,
|
||||
content: prompt,
|
||||
},
|
||||
],
|
||||
temperature,
|
||||
@@ -279,6 +289,10 @@ const genClaude = ({
|
||||
.replaceAll(INPUT_PLACE_FROM, from)
|
||||
.replaceAll(INPUT_PLACE_TO, to)
|
||||
.replaceAll(INPUT_PLACE_TEXT, text);
|
||||
systemPrompt = systemPrompt
|
||||
.replaceAll(INPUT_PLACE_FROM, from)
|
||||
.replaceAll(INPUT_PLACE_TO, to)
|
||||
.replaceAll(INPUT_PLACE_TEXT, text);
|
||||
|
||||
const data = {
|
||||
model,
|
||||
|
||||
@@ -527,7 +527,8 @@ const defaultOpenaiApi = {
|
||||
url: "https://api.openai.com/v1/chat/completions",
|
||||
key: "",
|
||||
model: "gpt-4",
|
||||
prompt: `You will be provided with a sentence in ${INPUT_PLACE_FROM}, and your task is to translate it into ${INPUT_PLACE_TO}.`,
|
||||
prompt: `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:`,
|
||||
systemPrompt: `You are a professional, authentic machine translation engine. You will be provided with a sentence in ${INPUT_PLACE_FROM}, and your task is to translate it into ${INPUT_PLACE_TO}.`,
|
||||
temperature: 0,
|
||||
maxTokens: 256,
|
||||
fetchLimit: 1,
|
||||
|
||||
@@ -237,7 +237,8 @@ function ApiFields({ translator }) {
|
||||
</>
|
||||
)}
|
||||
|
||||
{translator === OPT_TRANS_CLAUDE && (
|
||||
{(translator.startsWith(OPT_TRANS_OPENAI) ||
|
||||
translator === OPT_TRANS_CLAUDE) && (
|
||||
<>
|
||||
<TextField
|
||||
size="small"
|
||||
@@ -246,12 +247,6 @@ function ApiFields({ translator }) {
|
||||
value={systemPrompt}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{(translator.startsWith(OPT_TRANS_OPENAI) ||
|
||||
translator === OPT_TRANS_CLAUDE) && (
|
||||
<>
|
||||
<TextField
|
||||
size="small"
|
||||
label={"Temperature"}
|
||||
|
||||
Reference in New Issue
Block a user