mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 03:10:08 +08:00
fix: Update the state of the last message block as a fallback (#6076)
This commit is contained in:
parent
35e27944f7
commit
04cbeab1d9
@ -718,9 +718,17 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
|
||||
const usage = chunk.usage
|
||||
const originalFinishDelta = chunk.delta
|
||||
const originalFinishRawChunk = chunk.chunk
|
||||
|
||||
if (!isEmpty(finishReason)) {
|
||||
onChunk({ type: ChunkType.TEXT_COMPLETE, text: content })
|
||||
if (content) {
|
||||
onChunk({ type: ChunkType.TEXT_COMPLETE, text: content })
|
||||
}
|
||||
if (thinkingContent) {
|
||||
onChunk({
|
||||
type: ChunkType.THINKING_COMPLETE,
|
||||
text: thinkingContent,
|
||||
thinking_millsec: new Date().getTime() - time_first_token_millsec
|
||||
})
|
||||
}
|
||||
if (usage) {
|
||||
finalUsage.completion_tokens += usage.completion_tokens || 0
|
||||
finalUsage.prompt_tokens += usage.prompt_tokens || 0
|
||||
@ -812,7 +820,6 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
|
||||
if (toolResults.length) {
|
||||
await processToolResults(toolResults, idx)
|
||||
}
|
||||
|
||||
onChunk({
|
||||
type: ChunkType.BLOCK_COMPLETE,
|
||||
response: {
|
||||
|
||||
@ -622,6 +622,14 @@ const fetchAndProcessAssistantResponseImpl = async (
|
||||
const contextForUsage = userMsgIndex !== -1 ? orderedMsgs.slice(0, userMsgIndex + 1) : []
|
||||
const finalContextWithAssistant = [...contextForUsage, finalAssistantMsg]
|
||||
|
||||
if (lastBlockId) {
|
||||
const changes: Partial<MessageBlock> = {
|
||||
status: MessageBlockStatus.SUCCESS
|
||||
}
|
||||
dispatch(updateOneBlock({ id: lastBlockId, changes }))
|
||||
saveUpdatedBlockToDB(lastBlockId, assistantMsgId, topicId, getState)
|
||||
}
|
||||
|
||||
// 更新topic的name
|
||||
autoRenameTopic(assistant, topicId)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user