mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-06 21:35:52 +08:00
fix: handle AISDKError in chunk processing (#10801)
This commit is contained in:
parent
679043f26b
commit
dd65fa2f71
@ -9,7 +9,7 @@ import { Chunk, ChunkType } from '@renderer/types/chunk'
|
|||||||
import { ProviderSpecificError } from '@renderer/types/provider-specific-error'
|
import { ProviderSpecificError } from '@renderer/types/provider-specific-error'
|
||||||
import { formatErrorMessage } from '@renderer/utils/error'
|
import { formatErrorMessage } from '@renderer/utils/error'
|
||||||
import { convertLinks, flushLinkConverterBuffer } from '@renderer/utils/linkConverter'
|
import { convertLinks, flushLinkConverterBuffer } from '@renderer/utils/linkConverter'
|
||||||
import type { TextStreamPart, ToolSet } from 'ai'
|
import { AISDKError, type TextStreamPart, type ToolSet } from 'ai'
|
||||||
|
|
||||||
import { ToolCallChunkHandler } from './handleToolCallChunk'
|
import { ToolCallChunkHandler } from './handleToolCallChunk'
|
||||||
|
|
||||||
@ -342,11 +342,14 @@ export class AiSdkToChunkAdapter {
|
|||||||
case 'error':
|
case 'error':
|
||||||
this.onChunk({
|
this.onChunk({
|
||||||
type: ChunkType.ERROR,
|
type: ChunkType.ERROR,
|
||||||
error: new ProviderSpecificError({
|
error:
|
||||||
message: formatErrorMessage(chunk.error),
|
chunk.error instanceof AISDKError
|
||||||
provider: 'unknown',
|
? chunk.error
|
||||||
cause: chunk.error
|
: new ProviderSpecificError({
|
||||||
})
|
message: formatErrorMessage(chunk.error),
|
||||||
|
provider: 'unknown',
|
||||||
|
cause: chunk.error
|
||||||
|
})
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user