feat: Add support for AI log streaming (#8526)

Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
Omar Ajoue
2024-02-09 09:41:01 +00:00
committed by GitHub
parent ccc0ad5009
commit 7501ad8f3c
12 changed files with 259 additions and 38 deletions

View File

@@ -787,6 +787,7 @@ type BaseExecutionFunctions = FunctionsBaseWithRequiredKeys<'getMode'> & {
getInputSourceData(inputIndex?: number, inputName?: string): ISourceData;
getExecutionCancelSignal(): AbortSignal | undefined;
onExecutionCancellation(handler: () => unknown): void;
logAiEvent(eventName: EventNamesAiNodesType, msg?: string | undefined): Promise<void>;
};
// TODO: Create later own type only for Config-Nodes
@@ -1945,6 +1946,24 @@ export interface IWorkflowExecuteHooks {
sendResponse?: Array<(response: IExecuteResponsePromiseData) => Promise<void>>;
}
export const eventNamesAiNodes = [
'n8n.ai.memory.get.messages',
'n8n.ai.memory.added.message',
'n8n.ai.output.parser.get.instructions',
'n8n.ai.output.parser.parsed',
'n8n.ai.retriever.get.relevant.documents',
'n8n.ai.embeddings.embedded.document',
'n8n.ai.embeddings.embedded.query',
'n8n.ai.document.processed',
'n8n.ai.text.splitter.split',
'n8n.ai.tool.called',
'n8n.ai.vector.store.searched',
'n8n.ai.llm.generated',
'n8n.ai.vector.store.populated',
] as const;
export type EventNamesAiNodesType = (typeof eventNamesAiNodes)[number];
export interface IWorkflowExecuteAdditionalData {
credentialsHelper: ICredentialsHelper;
executeWorkflow: (
@@ -1978,6 +1997,17 @@ export interface IWorkflowExecuteAdditionalData {
userId: string;
variables: IDataObject;
secretsHelpers: SecretsHelpersBase;
logAiEvent: (
eventName: EventNamesAiNodesType,
payload: {
msg?: string;
executionId: string;
nodeName: string;
workflowId?: string;
workflowName: string;
nodeType?: string;
},
) => Promise<void>;
}
export type WorkflowExecuteMode =

View File

@@ -11,6 +11,7 @@ export const enum EventMessageTypeNames {
confirm = '$$EventMessageConfirm',
workflow = '$$EventMessageWorkflow',
node = '$$EventMessageNode',
aiNode = '$$EventMessageAiNode',
}
export const enum MessageEventBusDestinationTypeNames {