ollama接口设置增加<think>块忽略参数
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
|||||||
import { sha256 } from "../libs/utils";
|
import { sha256 } from "../libs/utils";
|
||||||
import interpreter from "../libs/interpreter";
|
import interpreter from "../libs/interpreter";
|
||||||
import { msAuth } from "../libs/auth";
|
import { msAuth } from "../libs/auth";
|
||||||
|
import {getSettingWithDefault } from "../libs/storage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步数据
|
* 同步数据
|
||||||
@@ -323,7 +324,8 @@ export const apiTranslate = async ({
|
|||||||
case OPT_TRANS_OLLAMA:
|
case OPT_TRANS_OLLAMA:
|
||||||
case OPT_TRANS_OLLAMA_2:
|
case OPT_TRANS_OLLAMA_2:
|
||||||
case OPT_TRANS_OLLAMA_3:
|
case OPT_TRANS_OLLAMA_3:
|
||||||
const deepModels = ['deepseek-r1', 'qwen3'];
|
let deepModels = (await getSettingWithDefault()).transApis[translator]?.thinkIgnore || '';
|
||||||
|
deepModels = deepModels.split(',').filter(model => model.trim() !== '');
|
||||||
if (deepModels.some(model => res?.model?.startsWith(model))) {
|
if (deepModels.some(model => res?.model?.startsWith(model))) {
|
||||||
trText = res?.response.replace(/<think>[\s\S]*<\/think>/i, '');
|
trText = res?.response.replace(/<think>[\s\S]*<\/think>/i, '');
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ export const I18N = {
|
|||||||
zh: `最大并发请求数量 (1-100)`,
|
zh: `最大并发请求数量 (1-100)`,
|
||||||
en: `Maximum Number Of Concurrent Requests (1-100)`,
|
en: `Maximum Number Of Concurrent Requests (1-100)`,
|
||||||
},
|
},
|
||||||
|
think_ignore: {
|
||||||
|
zh: `忽略以下模型的<think>输出,逗号(,)分割`,
|
||||||
|
en: `Ignore the <think> block for the following models, comma (,) separated`,
|
||||||
|
},
|
||||||
fetch_interval: {
|
fetch_interval: {
|
||||||
zh: `每次请求间隔时间 (0-5000ms)`,
|
zh: `每次请求间隔时间 (0-5000ms)`,
|
||||||
en: `Time Between Requests (0-5000ms)`,
|
en: `Time Between Requests (0-5000ms)`,
|
||||||
|
|||||||
@@ -541,6 +541,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:`,
|
||||||
|
thinkIgnore:`qwen3,deepseek-r1`,
|
||||||
fetchLimit: 1,
|
fetchLimit: 1,
|
||||||
fetchInterval: 500,
|
fetchInterval: 500,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ function ApiFields({ translator }) {
|
|||||||
model = "",
|
model = "",
|
||||||
systemPrompt = "",
|
systemPrompt = "",
|
||||||
userPrompt = "",
|
userPrompt = "",
|
||||||
|
thinkIgnore = "",
|
||||||
fetchLimit = DEFAULT_FETCH_LIMIT,
|
fetchLimit = DEFAULT_FETCH_LIMIT,
|
||||||
fetchInterval = DEFAULT_FETCH_INTERVAL,
|
fetchInterval = DEFAULT_FETCH_INTERVAL,
|
||||||
dictNo = "",
|
dictNo = "",
|
||||||
@@ -246,6 +247,18 @@ function ApiFields({ translator }) {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{(translator.startsWith(OPT_TRANS_OLLAMA)) && (
|
||||||
|
<>
|
||||||
|
<TextField
|
||||||
|
size="small"
|
||||||
|
label={i18n("think_ignore")}
|
||||||
|
name="thinkIgnore"
|
||||||
|
value={thinkIgnore}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{(translator.startsWith(OPT_TRANS_OPENAI) ||
|
{(translator.startsWith(OPT_TRANS_OPENAI) ||
|
||||||
translator === OPT_TRANS_CLAUDE) && (
|
translator === OPT_TRANS_CLAUDE) && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user