mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 05:11:24 +08:00
fix: unexpected chunk
This commit is contained in:
parent
3e5969b97c
commit
89cbf80008
@ -71,6 +71,7 @@ export type {
|
||||
ToolCallUnion,
|
||||
ToolModelMessage,
|
||||
ToolResultPart,
|
||||
ToolResultUnion,
|
||||
ToolSet,
|
||||
UserModelMessage
|
||||
} from 'ai'
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* 提供工具调用相关的处理API,每个交互使用一个新的实例
|
||||
*/
|
||||
|
||||
import { ToolCallUnion, ToolSet } from '@cherrystudio/ai-core/index'
|
||||
import { ToolCallUnion, ToolResultUnion, ToolSet } from '@cherrystudio/ai-core/index'
|
||||
import Logger from '@renderer/config/logger'
|
||||
import { MCPTool, MCPToolResponse } from '@renderer/types'
|
||||
import { Chunk, ChunkType } from '@renderer/types/chunk'
|
||||
@ -84,9 +84,13 @@ export class ToolCallChunkHandler {
|
||||
/**
|
||||
* 处理工具调用结果事件
|
||||
*/
|
||||
public handleToolResult(chunk: any): void {
|
||||
public handleToolResult(
|
||||
chunk: {
|
||||
type: 'tool-result'
|
||||
} & ToolResultUnion<ToolSet>
|
||||
): void {
|
||||
const toolCallId = chunk.toolCallId
|
||||
const result = chunk.result
|
||||
const result = chunk.output
|
||||
|
||||
if (!toolCallId) {
|
||||
Logger.warn(`🔧 [ToolCallChunkHandler] Invalid tool result chunk: missing toolCallId`)
|
||||
|
||||
@ -49,7 +49,9 @@ export default definePlugin({
|
||||
reasoningBlockId = ''
|
||||
controller.enqueue(chunk)
|
||||
} else {
|
||||
controller.enqueue(chunk)
|
||||
if (chunk.type !== 'reasoning-end') {
|
||||
controller.enqueue(chunk)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ import {
|
||||
import { getStoreSetting } from '@renderer/hooks/useSettings'
|
||||
import i18n from '@renderer/i18n'
|
||||
import store from '@renderer/store'
|
||||
import { Assistant, MCPTool, Model, Provider } from '@renderer/types'
|
||||
import { Assistant, MCPServer, MCPTool, Model, Provider } from '@renderer/types'
|
||||
import { type Chunk, ChunkType } from '@renderer/types/chunk'
|
||||
import { Message } from '@renderer/types/newMessage'
|
||||
import { SdkModel } from '@renderer/types/sdk'
|
||||
@ -263,7 +263,7 @@ export async function fetchMcpTools(assistant: Assistant) {
|
||||
|
||||
if (enabledMCPs && enabledMCPs.length > 0) {
|
||||
try {
|
||||
const toolPromises = enabledMCPs.map<Promise<MCPTool[]>>(async (mcpServer) => {
|
||||
const toolPromises = enabledMCPs.map<Promise<MCPTool[]>>(async (mcpServer: MCPServer) => {
|
||||
try {
|
||||
const tools = await window.api.mcp.listTools(mcpServer)
|
||||
return tools.filter((tool: any) => !mcpServer.disabledTools?.includes(tool.name))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user