mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-09 14:59:27 +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) => {
|
.on('text', (text) => {
|
||||||
if (hasThinkingContent && !checkThinkingContent) {
|
if (hasThinkingContent && !checkThinkingContent) {
|
||||||
checkThinkingContent = true
|
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) {
|
if (time_first_token_millsec == 0) {
|
||||||
time_first_token_millsec = new Date().getTime() - start_time_millsec
|
time_first_token_millsec = new Date().getTime() - start_time_millsec
|
||||||
|
|||||||
@ -559,6 +559,12 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
text: thinkingContent,
|
text: thinkingContent,
|
||||||
thinking_millsec: final_time_thinking_millsec_delta
|
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) {
|
if (newBlockType !== MessageBlockType.MAIN_TEXT) {
|
||||||
accumulatedContent = ''
|
accumulatedContent = ''
|
||||||
}
|
}
|
||||||
|
if (newBlockType !== MessageBlockType.THINKING) {
|
||||||
|
accumulatedThinking = ''
|
||||||
|
}
|
||||||
console.log(`[Transition] Adding/Updating new ${newBlockType} block ${newBlock.id}.`)
|
console.log(`[Transition] Adding/Updating new ${newBlockType} block ${newBlock.id}.`)
|
||||||
dispatch(
|
dispatch(
|
||||||
newMessagesActions.updateMessage({
|
newMessagesActions.updateMessage({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user