mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 15:49:29 +08:00
fix(assistant): update translate assistant content handling for QwenMT model (#10306)
* fix(assistant): update translate assistant content handling for QwenMT model - Adjusted content assignment in getDefaultTranslateAssistant to use store settings only when the model is not a QwenMT model, ensuring correct translation behavior. * lint err * refactor(assistant): encapsulate content handling logic for translation - Introduced a new function, getTranslateContent, to streamline content assignment in getDefaultTranslateAssistant. - This change improves readability and maintains correct translation behavior for QwenMT models. * format code
This commit is contained in:
parent
87d9c7b410
commit
25c5d671dc
@ -2,7 +2,7 @@ import { loggerService } from '@logger'
|
|||||||
import { isWin } from '@main/constant'
|
import { isWin } from '@main/constant'
|
||||||
import { getIpCountry } from '@main/utils/ipService'
|
import { getIpCountry } from '@main/utils/ipService'
|
||||||
import { locales } from '@main/utils/locales'
|
import { locales } from '@main/utils/locales'
|
||||||
import { generateClientTelemetryHeader, generateUserAgent } from '@main/utils/systemInfo'
|
import { generateUserAgent } from '@main/utils/systemInfo'
|
||||||
import { FeedUrl, UpgradeChannel } from '@shared/config/constant'
|
import { FeedUrl, UpgradeChannel } from '@shared/config/constant'
|
||||||
import { IpcChannel } from '@shared/IpcChannel'
|
import { IpcChannel } from '@shared/IpcChannel'
|
||||||
import { CancellationToken, UpdateInfo } from 'builder-util-runtime'
|
import { CancellationToken, UpdateInfo } from 'builder-util-runtime'
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {
|
|||||||
MAX_CONTEXT_COUNT,
|
MAX_CONTEXT_COUNT,
|
||||||
UNLIMITED_CONTEXT_COUNT
|
UNLIMITED_CONTEXT_COUNT
|
||||||
} from '@renderer/config/constant'
|
} from '@renderer/config/constant'
|
||||||
|
import { isQwenMTModel } from '@renderer/config/models'
|
||||||
import { UNKNOWN } from '@renderer/config/translate'
|
import { UNKNOWN } from '@renderer/config/translate'
|
||||||
import i18n from '@renderer/i18n'
|
import i18n from '@renderer/i18n'
|
||||||
import store from '@renderer/store'
|
import store from '@renderer/store'
|
||||||
@ -69,11 +70,18 @@ export function getDefaultTranslateAssistant(targetLanguage: TranslateLanguage,
|
|||||||
temperature: 0.7
|
temperature: 0.7
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = store
|
const getTranslateContent = (model: Model, text: string, targetLanguage: TranslateLanguage): string => {
|
||||||
.getState()
|
if (isQwenMTModel(model)) {
|
||||||
.settings.translateModelPrompt.replaceAll('{{target_language}}', targetLanguage.value)
|
return text // QwenMT models handle raw text directly
|
||||||
.replaceAll('{{text}}', text)
|
}
|
||||||
|
|
||||||
|
return store
|
||||||
|
.getState()
|
||||||
|
.settings.translateModelPrompt.replaceAll('{{target_language}}', targetLanguage.value)
|
||||||
|
.replaceAll('{{text}}', text)
|
||||||
|
}
|
||||||
|
|
||||||
|
const content = getTranslateContent(model, text, targetLanguage)
|
||||||
const translateAssistant = {
|
const translateAssistant = {
|
||||||
...assistant,
|
...assistant,
|
||||||
model,
|
model,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user