mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
fix: refresh thinking state on streaming (#5557)
This commit is contained in:
parent
d571c46aad
commit
f9690d52ee
@ -259,7 +259,17 @@ export default class AnthropicProvider extends BaseProvider {
|
||||
.on('text', (text) => {
|
||||
if (hasThinkingContent && !checkThinkingContent) {
|
||||
checkThinkingContent = true
|
||||
onChunk({ type: ChunkType.THINKING_COMPLETE, text: thinking_content, thinking_millsec: 0 })
|
||||
onChunk({
|
||||
type: ChunkType.THINKING_COMPLETE,
|
||||
text: thinking_content,
|
||||
thinking_millsec: time_first_content_millsec - time_first_token_millsec
|
||||
})
|
||||
// FIXME: 临时方案,重置时间戳和思考内容
|
||||
time_first_token_millsec = 0
|
||||
time_first_content_millsec = 0
|
||||
thinking_content = ''
|
||||
checkThinkingContent = false
|
||||
hasThinkingContent = false
|
||||
}
|
||||
if (time_first_token_millsec == 0) {
|
||||
time_first_token_millsec = new Date().getTime() - start_time_millsec
|
||||
|
||||
@ -559,6 +559,12 @@ export default class OpenAIProvider extends BaseProvider {
|
||||
text: thinkingContent,
|
||||
thinking_millsec: final_time_thinking_millsec_delta
|
||||
})
|
||||
|
||||
// FIXME: 临时方案,重置时间戳和思考内容
|
||||
time_first_token_millsec = 0
|
||||
time_first_content_millsec = 0
|
||||
thinkingContent = ''
|
||||
isFirstThinkingChunk = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -280,6 +280,9 @@ const fetchAndProcessAssistantResponseImpl = async (
|
||||
if (newBlockType !== MessageBlockType.MAIN_TEXT) {
|
||||
accumulatedContent = ''
|
||||
}
|
||||
if (newBlockType !== MessageBlockType.THINKING) {
|
||||
accumulatedThinking = ''
|
||||
}
|
||||
console.log(`[Transition] Adding/Updating new ${newBlockType} block ${newBlock.id}.`)
|
||||
dispatch(
|
||||
newMessagesActions.updateMessage({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user