mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-31 00:10:22 +08:00
refactor(TranslateService): remove content parameter to reduce token (#9567)
* refactor(TranslateService): remove content parameter from fetchTranslate function - Updated fetchTranslate function to eliminate the content parameter, simplifying its signature. - Adjusted related calls to ensure compatibility with the new function definition, maintaining functionality while improving code clarity. * Update src/renderer/src/services/TranslateService.ts --------- Co-authored-by: Phantom <59059173+EurFelux@users.noreply.github.com>
This commit is contained in:
parent
bd4ba47e61
commit
eac71f1f43
@ -22,12 +22,11 @@ import {
|
||||
|
||||
const logger = loggerService.withContext('TranslateService')
|
||||
interface FetchTranslateProps {
|
||||
content: string
|
||||
assistant: TranslateAssistant
|
||||
onResponse?: (text: string, isComplete: boolean) => void
|
||||
}
|
||||
|
||||
async function fetchTranslate({ content, assistant, onResponse }: FetchTranslateProps) {
|
||||
async function fetchTranslate({ assistant, onResponse }: FetchTranslateProps) {
|
||||
const model = getTranslateModel() || assistant.model || getDefaultModel()
|
||||
|
||||
if (!model) {
|
||||
@ -55,7 +54,7 @@ async function fetchTranslate({ content, assistant, onResponse }: FetchTranslate
|
||||
|
||||
const params: CompletionsParams = {
|
||||
callType: 'translate',
|
||||
messages: content,
|
||||
messages: 'do',
|
||||
assistant: { ...assistant, model },
|
||||
streamOutput: stream,
|
||||
enableReasoning,
|
||||
@ -83,7 +82,7 @@ export const translateText = async (
|
||||
try {
|
||||
const assistant = getDefaultTranslateAssistant(targetLanguage, text)
|
||||
|
||||
const translatedText = await fetchTranslate({ content: text, assistant, onResponse })
|
||||
const translatedText = await fetchTranslate({ assistant, onResponse })
|
||||
|
||||
const trimmedText = translatedText.trim()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user