feat: Translation does not show the thinking content
This commit is contained in:
parent
46c7d35bb8
commit
32749d65a4
@ -520,10 +520,33 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let text = ''
|
let text = ''
|
||||||
|
let isThinking = false
|
||||||
|
const isReasoning = isReasoningModel(model)
|
||||||
|
|
||||||
for await (const chunk of response) {
|
for await (const chunk of response) {
|
||||||
text += chunk.choices[0]?.delta?.content || ''
|
const deltaContent = chunk.choices[0]?.delta?.content || ''
|
||||||
onResponse?.(text)
|
|
||||||
|
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
|
return text
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user