From 471dc05897b1cbc62fc60c5e801f6fbc93d2b066 Mon Sep 17 00:00:00 2001 From: mcz Date: Thu, 1 May 2025 23:41:08 +0800 Subject: [PATCH] =?UTF-8?q?ollama=E6=8E=A5=E5=8F=A3=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9D=97=E5=BF=BD=E7=95=A5=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/index.js | 4 +++- src/config/i18n.js | 4 ++++ src/config/index.js | 1 + src/views/Options/Apis.js | 13 +++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/apis/index.js b/src/apis/index.js index a35e726..cb7416b 100644 --- a/src/apis/index.js +++ b/src/apis/index.js @@ -39,6 +39,7 @@ import { import { sha256 } from "../libs/utils"; import interpreter from "../libs/interpreter"; 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_2: 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))) { trText = res?.response.replace(/[\s\S]*<\/think>/i, ''); }else{ diff --git a/src/config/i18n.js b/src/config/i18n.js index 908e9e0..f69ae44 100644 --- a/src/config/i18n.js +++ b/src/config/i18n.js @@ -186,6 +186,10 @@ export const I18N = { zh: `最大并发请求数量 (1-100)`, en: `Maximum Number Of Concurrent Requests (1-100)`, }, + think_ignore: { + zh: `忽略以下模型的输出,逗号(,)分割`, + en: `Ignore the block for the following models, comma (,) separated`, + }, fetch_interval: { zh: `每次请求间隔时间 (0-5000ms)`, en: `Time Between Requests (0-5000ms)`, diff --git a/src/config/index.js b/src/config/index.js index 2d65bef..94e0c01 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -541,6 +541,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:`, + thinkIgnore:`qwen3,deepseek-r1`, fetchLimit: 1, fetchInterval: 500, }; diff --git a/src/views/Options/Apis.js b/src/views/Options/Apis.js index 55f17fc..af66062 100644 --- a/src/views/Options/Apis.js +++ b/src/views/Options/Apis.js @@ -117,6 +117,7 @@ function ApiFields({ translator }) { model = "", systemPrompt = "", userPrompt = "", + thinkIgnore = "", fetchLimit = DEFAULT_FETCH_LIMIT, fetchInterval = DEFAULT_FETCH_INTERVAL, dictNo = "", @@ -246,6 +247,18 @@ function ApiFields({ translator }) { )} + {(translator.startsWith(OPT_TRANS_OLLAMA)) && ( + <> + + + )} + {(translator.startsWith(OPT_TRANS_OPENAI) || translator === OPT_TRANS_CLAUDE) && ( <>