feat(AI Agent Node): Implement streaming on AI agent node (no-changelog) (#16897)

This commit is contained in:
Benjamin Schroth
2025-07-04 09:21:48 +02:00
committed by GitHub
parent bd69907477
commit 5a5848aa42
13 changed files with 401 additions and 14 deletions

View File

@@ -131,6 +131,21 @@ export class ExecuteContext extends BaseExecuteContext implements IExecuteFuncti
)) as IExecuteFunctions['getNodeParameter'];
}
isStreaming(): boolean {
// Check if we have sendChunk handlers
const handlers = this.additionalData.hooks?.handlers?.sendChunk?.length;
const hasHandlers = handlers !== undefined && handlers > 0;
// Check if streaming was enabled for this execution
const streamingEnabled = this.additionalData.streamingEnabled === true;
// Check current execution mode supports streaming
const executionModeSupportsStreaming = ['manual', 'webhook', 'integrated'];
const isStreamingMode = executionModeSupportsStreaming.includes(this.mode);
return hasHandlers && isStreamingMode && streamingEnabled;
}
async sendChunk(type: ChunkType, content?: IDataObject | string): Promise<void> {
const node = this.getNode();
const metadata = {
@@ -139,9 +154,11 @@ export class ExecuteContext extends BaseExecuteContext implements IExecuteFuncti
timestamp: Date.now(),
};
const parsedContent = typeof content === 'string' ? content : JSON.stringify(content);
const message: StructuredChunk = {
type,
content: content ? JSON.stringify(content) : undefined,
content: parsedContent,
metadata,
};