@@ -97,9 +97,25 @@ export class QueryAgent {
9797 * @param options - Additional options for the run.
9898 * @returns The response from the query agent.
9999 */
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 > ;
100116 async * stream (
101117 query : string ,
102- { collections, context, includeProgress } : QueryAgentStreamOptions = { }
118+ { collections, context, includeProgress, includeFinalState } : QueryAgentStreamOptions = { }
103119 ) : AsyncGenerator < ProgressMessage | StreamedTokens | QueryAgentResponse > {
104120 const targetCollections = collections ?? this . collections ;
105121
@@ -126,6 +142,7 @@ export class QueryAgent {
126142 system_prompt : this . systemPrompt ,
127143 previous_response : context ? mapApiResponse ( context ) : undefined ,
128144 include_progress : includeProgress ?? true ,
145+ include_final_state : includeFinalState ?? true ,
129146 } ) ,
130147 }
131148 ) ;
@@ -177,4 +194,6 @@ export type QueryAgentStreamOptions = {
177194 context ?: QueryAgentResponse ;
178195 /** Include progress messages in the stream. */
179196 includeProgress ?: boolean ;
197+ /** Include final state in the stream. */
198+ includeFinalState ?: boolean ;
180199} ;
0 commit comments