File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -138,12 +138,24 @@ export async function* processStreamWithTags(
138138 processor . onTagEnd ( toolName , parsedParams )
139139 }
140140
141- function extractToolsFromBufferAndProcess ( ) {
141+ function * extractToolsFromBufferAndProcess (
142+ forceFlush = true ,
143+ ) : Generator < StreamChunk > {
142144 const matches = extractToolCalls ( )
143145 matches . forEach ( processToolCallContents )
146+ if ( forceFlush ) {
147+ const chunk : StreamChunk = {
148+ type : 'text' ,
149+ text : buffer ,
150+ }
151+ yield chunk
152+ onResponseChunk ( chunk )
153+ }
144154 }
145155
146- function * processChunk ( chunk : StreamChunk | undefined ) {
156+ function * processChunk (
157+ chunk : StreamChunk | undefined ,
158+ ) : Generator < StreamChunk > {
147159 if ( chunk !== undefined && chunk . type === 'text' ) {
148160 buffer += chunk . text
149161 }
@@ -159,7 +171,7 @@ export async function* processStreamWithTags(
159171 }
160172 autocompleted = true
161173 }
162- extractToolsFromBufferAndProcess ( )
174+ yield * extractToolsFromBufferAndProcess ( true )
163175 }
164176
165177 if ( chunk ) {
You can’t perform that action at this time.
0 commit comments