mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
feat: Translation does not show the thinking content
This commit is contained in:
parent
0776cda8b5
commit
cb0313e0a6
@ -520,10 +520,33 @@ export default class OpenAIProvider extends BaseProvider {
|
||||
}
|
||||
|
||||
let text = ''
|
||||
let isThinking = false
|
||||
const isReasoning = isReasoningModel(model)
|
||||
|
||||
for await (const chunk of response) {
|
||||
text += chunk.choices[0]?.delta?.content || ''
|
||||
onResponse?.(text)
|
||||
const deltaContent = chunk.choices[0]?.delta?.content || ''
|
||||
|
||||
if (!deltaContent.trim()) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (isReasoning) {
|
||||
if (deltaContent.includes('<think>')) {
|
||||
isThinking = true
|
||||
}
|
||||
|
||||
if (!isThinking) {
|
||||
text += deltaContent
|
||||
onResponse?.(text)
|
||||
}
|
||||
|
||||
if (deltaContent.includes('</think>')) {
|
||||
isThinking = false
|
||||
}
|
||||
} else {
|
||||
text += deltaContent
|
||||
onResponse?.(text)
|
||||
}
|
||||
}
|
||||
|
||||
return text
|
||||
|
||||
Loading…
Reference in New Issue
Block a user