mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 05:11:24 +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 { getIpCountry } from '@main/utils/ipService'
|
||||
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 { IpcChannel } from '@shared/IpcChannel'
|
||||
import { CancellationToken, UpdateInfo } from 'builder-util-runtime'
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
MAX_CONTEXT_COUNT,
|
||||
UNLIMITED_CONTEXT_COUNT
|
||||
} from '@renderer/config/constant'
|
||||
import { isQwenMTModel } from '@renderer/config/models'
|
||||
import { UNKNOWN } from '@renderer/config/translate'
|
||||
import i18n from '@renderer/i18n'
|
||||
import store from '@renderer/store'
|
||||
@ -69,11 +70,18 @@ export function getDefaultTranslateAssistant(targetLanguage: TranslateLanguage,
|
||||
temperature: 0.7
|
||||
}
|
||||
|
||||
const content = store
|
||||
.getState()
|
||||
.settings.translateModelPrompt.replaceAll('{{target_language}}', targetLanguage.value)
|
||||
.replaceAll('{{text}}', text)
|
||||
const getTranslateContent = (model: Model, text: string, targetLanguage: TranslateLanguage): string => {
|
||||
if (isQwenMTModel(model)) {
|
||||
return text // QwenMT models handle raw text directly
|
||||
}
|
||||
|
||||
return store
|
||||
.getState()
|
||||
.settings.translateModelPrompt.replaceAll('{{target_language}}', targetLanguage.value)
|
||||
.replaceAll('{{text}}', text)
|
||||
}
|
||||
|
||||
const content = getTranslateContent(model, text, targetLanguage)
|
||||
const translateAssistant = {
|
||||
...assistant,
|
||||
model,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user