mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(Structured Output Parser Node): Refactor Output Parsers and Improve Error Handling (#11148)
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { NodeConnectionType, NodeOperationError, jsonStringify } from 'n8n-workflow';
|
||||
import type { AiEvent, IDataObject, IExecuteFunctions, IWebhookFunctions } from 'n8n-workflow';
|
||||
import type { BaseChatMessageHistory } from '@langchain/core/chat_history';
|
||||
import type { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
||||
import type { BaseOutputParser } from '@langchain/core/output_parsers';
|
||||
import type { BaseLLM } from '@langchain/core/language_models/llms';
|
||||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
import type { Tool } from '@langchain/core/tools';
|
||||
import type { BaseLLM } from '@langchain/core/language_models/llms';
|
||||
import type { BaseChatMemory } from 'langchain/memory';
|
||||
import type { BaseChatMessageHistory } from '@langchain/core/chat_history';
|
||||
import { NodeConnectionType, NodeOperationError, jsonStringify } from 'n8n-workflow';
|
||||
import type { AiEvent, IDataObject, IExecuteFunctions, IWebhookFunctions } from 'n8n-workflow';
|
||||
|
||||
import { N8nTool } from './N8nTool';
|
||||
|
||||
function hasMethods<T>(obj: unknown, ...methodNames: Array<string | symbol>): obj is T {
|
||||
@@ -66,21 +66,6 @@ export function isToolsInstance(model: unknown): model is Tool {
|
||||
return namespace.includes('tools');
|
||||
}
|
||||
|
||||
export async function getOptionalOutputParsers(
|
||||
ctx: IExecuteFunctions,
|
||||
): Promise<Array<BaseOutputParser<unknown>>> {
|
||||
let outputParsers: BaseOutputParser[] = [];
|
||||
|
||||
if (ctx.getNodeParameter('hasOutputParser', 0, true) === true) {
|
||||
outputParsers = (await ctx.getInputConnectionData(
|
||||
NodeConnectionType.AiOutputParser,
|
||||
0,
|
||||
)) as BaseOutputParser[];
|
||||
}
|
||||
|
||||
return outputParsers;
|
||||
}
|
||||
|
||||
export function getPromptInputByType(options: {
|
||||
ctx: IExecuteFunctions;
|
||||
i: number;
|
||||
|
||||
Reference in New Issue
Block a user