@@ -97,9 +97,25 @@ export class QueryAgent {
97
97
* @param options - Additional options for the run.
98
98
* @returns The response from the query agent.
99
99
*/
100
+ stream (
101
+ query : string ,
102
+ options : QueryAgentStreamOptions & { includeProgress : false ; includeFinalState : false }
103
+ ) : AsyncGenerator < StreamedTokens > ;
104
+ stream (
105
+ query : string ,
106
+ options : QueryAgentStreamOptions & { includeProgress : false ; includeFinalState ?: true }
107
+ ) : AsyncGenerator < StreamedTokens | QueryAgentResponse > ;
108
+ stream (
109
+ query : string ,
110
+ options : QueryAgentStreamOptions & { includeProgress ?: true ; includeFinalState : false }
111
+ ) : AsyncGenerator < ProgressMessage | StreamedTokens > ;
112
+ stream (
113
+ query : string ,
114
+ options ?: QueryAgentStreamOptions & { includeProgress ?: true ; includeFinalState ?: true }
115
+ ) : AsyncGenerator < ProgressMessage | StreamedTokens | QueryAgentResponse > ;
100
116
async * stream (
101
117
query : string ,
102
- { collections, context, includeProgress } : QueryAgentStreamOptions = { }
118
+ { collections, context, includeProgress, includeFinalState } : QueryAgentStreamOptions = { }
103
119
) : AsyncGenerator < ProgressMessage | StreamedTokens | QueryAgentResponse > {
104
120
const targetCollections = collections ?? this . collections ;
105
121
@@ -126,6 +142,7 @@ export class QueryAgent {
126
142
system_prompt : this . systemPrompt ,
127
143
previous_response : context ? mapApiResponse ( context ) : undefined ,
128
144
include_progress : includeProgress ?? true ,
145
+ include_final_state : includeFinalState ?? true ,
129
146
} ) ,
130
147
}
131
148
) ;
@@ -177,4 +194,6 @@ export type QueryAgentStreamOptions = {
177
194
context ?: QueryAgentResponse ;
178
195
/** Include progress messages in the stream. */
179
196
includeProgress ?: boolean ;
197
+ /** Include final state in the stream. */
198
+ includeFinalState ?: boolean ;
180
199
} ;
0 commit comments