Fix smooth streaming
| @@ -109,7 +109,7 @@ function getDelay(s) { | ||
| 109 | 109 | */ |
| 110 | 110 | async function* parseStreamData(json) { |
| 111 | 111 | // Cohere |
| 112 | 112 | if (typeof json.delta === 'object' && typeof json.delta.message === 'object' && ['tool-plan-delta', 'content-delta'].includes(json.type)) { |
| 113 | 113 | const text = json?.delta?.message?.content?.text ?? ''; |
| 114 | 114 | for (let i = 0; i < text.length; i++) { |
| 115 | 115 | const str = json.delta.message.content.text[i]; |
| @@ -121,7 +121,7 @@ async function* parseStreamData(json) { | ||
| 121 | 121 | return; |
| 122 | 122 | } |
| 123 | 123 | // Claude |
| 124 | 124 | else if (typeof json.delta === 'object' && typeof json.delta.text === 'string') { |
| 125 | 125 | if (json.delta.text.length > 0) { |
| 126 | 126 | for (let i = 0; i < json.delta.text.length; i++) { |
| 127 | 127 | const str = json.delta.text[i]; |