Mismatched content block type content_block_delta thinking View output logs · Tr...
错误信息
Mismatched content block type content_block_delta thinking
View output logs · Troubleshooting resources
AI 解决方案
报错分析报告
1.错误翻译
原文:Mismatched content block type content_block_delta thinking
译文:内容块类型不匹配:content_block_delta 与 thinking
2. 原因分析
content_block_delta)与预期类型(thinking)不一致。 3. 解决方案
以OpenAI-style流式块为例,修复类型匹配问题:
// 修复前(错误):混用类型
stream.write({ type: "content_block_delta", content: "思考中..." }); // 错误类型
stream.write({ type: "thinking", content: "分析逻辑" }); // 正确类型但顺序/逻辑错
// 修复后(正确):按类型规范发送
// 1. 若需发送“思考过程”,用 thinking 块
stream.write({ type: "thinking", content: "正在分析用户需求..." });
// 2. 若需发送“内容增量”,用 content_block_delta 块
stream.write({ type: "content_block_delta", delta: { text: "分析结果..." } });
4. 预防措施
thinking用于内部推理、content_block_delta用于最终内容增量),避免跨类型混用。 interface ThinkingBlock { type: "thinking"; content: string }
interface ContentDeltaBlock { type: "content_block_delta"; delta: { text: string } }
type ValidBlock = ThinkingBlock | ContentDeltaBlock;
ajv做JSON Schema校验,或IDE插件(如VSCode的TypeScript Importer)实时提示类型错误。---
注:若报错来自特定平台(如DMXAPI),请补充完整日志以细化方案。