mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): All calls to supplyData should use a distinct context type (no-changelog) (#11421)
This commit is contained in:
committed by
GitHub
parent
04c075a46b
commit
8f5fe05a92
@@ -7,7 +7,7 @@ import type {
|
||||
SerializedSecret,
|
||||
} from '@langchain/core/load/serializable';
|
||||
import type { LLMResult } from '@langchain/core/outputs';
|
||||
import type { IDataObject, IExecuteFunctions } from 'n8n-workflow';
|
||||
import type { IDataObject, ISupplyDataFunctions } from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import { pick } from 'lodash';
|
||||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
@@ -30,8 +30,6 @@ const TIKTOKEN_ESTIMATE_MODEL = 'gpt-4o';
|
||||
export class N8nLlmTracing extends BaseCallbackHandler {
|
||||
name = 'N8nLlmTracing';
|
||||
|
||||
executionFunctions: IExecuteFunctions;
|
||||
|
||||
connectionType = NodeConnectionType.AiLanguageModel;
|
||||
|
||||
promptTokensEstimate = 0;
|
||||
@@ -61,11 +59,10 @@ export class N8nLlmTracing extends BaseCallbackHandler {
|
||||
};
|
||||
|
||||
constructor(
|
||||
executionFunctions: IExecuteFunctions,
|
||||
private executionFunctions: ISupplyDataFunctions,
|
||||
options?: { tokensUsageParser: TokensUsageParser },
|
||||
) {
|
||||
super();
|
||||
this.executionFunctions = executionFunctions;
|
||||
this.options = { ...this.options, ...options };
|
||||
}
|
||||
|
||||
@@ -138,7 +135,7 @@ export class N8nLlmTracing extends BaseCallbackHandler {
|
||||
this.executionFunctions.addOutputData(this.connectionType, runDetails.index, [
|
||||
[{ json: { ...response } }],
|
||||
]);
|
||||
void logAiEvent(this.executionFunctions, 'ai-llm-generated-output', {
|
||||
logAiEvent(this.executionFunctions, 'ai-llm-generated-output', {
|
||||
messages: parsedMessages,
|
||||
options: runDetails.options,
|
||||
response,
|
||||
@@ -186,7 +183,7 @@ export class N8nLlmTracing extends BaseCallbackHandler {
|
||||
});
|
||||
}
|
||||
|
||||
void logAiEvent(this.executionFunctions, 'ai-llm-errored', {
|
||||
logAiEvent(this.executionFunctions, 'ai-llm-errored', {
|
||||
error: Object.keys(error).length === 0 ? error.toString() : error,
|
||||
runId,
|
||||
parentRunId,
|
||||
|
||||
Reference in New Issue
Block a user