重构: CR-11 composables+ToolCard 健壮性 6 子项
⑦ useAiConversations JSON.parse 逐条 try/catch 容错(坏条降级不清空整对话);⑧ ToolCard 去 as any + argString 安全取字段;⑨ useAiSend approveToolCall 复用 findToolCall;⑩ useAiEvents 补 AiHeartbeat case 防穿透;⑪ approveHumanApproval 签名收敛(decisions:string[] + select_type 判单/多选)+ ProjectDetail 调用方同步(单选包数组/多选直传);⑫ ToolCard formatBytes/formatToolName/argString 兜底。批5 ww1mh6mry,vue-tsc 0
This commit is contained in:
@@ -74,15 +74,27 @@ export async function switchConversation(id: string) {
|
||||
content: m.content || '',
|
||||
model: m.model,
|
||||
timestamp: Date.now(),
|
||||
toolCalls: m.tool_calls?.map((tc: any) => ({
|
||||
id: tc.id,
|
||||
name: tc.function?.name || '',
|
||||
args: typeof tc.function?.arguments === 'string'
|
||||
? JSON.parse(tc.function.arguments || '{}')
|
||||
: tc.function?.arguments || {},
|
||||
status: 'completed' as const,
|
||||
result: toolResultMap.get(tc.id),
|
||||
})),
|
||||
toolCalls: m.tool_calls?.map((tc: any): AiToolCallInfo => {
|
||||
// 逐条容错:单条坏 arguments 仅降级为空对象,不影响整条对话回填
|
||||
let args: unknown = {}
|
||||
const rawArgs = tc.function?.arguments
|
||||
if (typeof rawArgs === 'string') {
|
||||
try {
|
||||
args = rawArgs ? JSON.parse(rawArgs) : {}
|
||||
} catch {
|
||||
args = {}
|
||||
}
|
||||
} else if (rawArgs && typeof rawArgs === 'object') {
|
||||
args = rawArgs
|
||||
}
|
||||
return {
|
||||
id: tc.id,
|
||||
name: tc.function?.name || '',
|
||||
args,
|
||||
status: 'completed' as const,
|
||||
result: toolResultMap.get(tc.id),
|
||||
}
|
||||
}),
|
||||
}))
|
||||
} catch {
|
||||
state.messages = []
|
||||
|
||||
Reference in New Issue
Block a user