| 109 | */ | 109 | */ |
| 110 | async function* parseStreamData(json) { | 110 | async function* parseStreamData(json) { |
| 111 | // Cohere | 111 | // Cohere |
| 112 | if (typeof json.delta.message === 'object' && ['tool-plan-delta', 'content-delta'].includes(json.type)) { | 112 | if (typeof json.delta === 'object' && typeof json.delta.message === 'object' && ['tool-plan-delta', 'content-delta'].includes(json.type)) { |
| 113 | const text = json?.delta?.message?.content?.text ?? ''; | 113 | const text = json?.delta?.message?.content?.text ?? ''; |
| 114 | for (let i = 0; i < text.length; i++) { | 114 | for (let i = 0; i < text.length; i++) { |
| 115 | const str = json.delta.message.content.text[i]; | 115 | const str = json.delta.message.content.text[i]; |