n8n/packages/@n8n/nodes-langchain/utils/output_parsers/N8nOutputParser.ts

27 lines
880 B
TypeScript

import type { IExecuteFunctions } from 'n8n-workflow';
import { NodeConnectionType } from 'n8n-workflow';
import { N8nItemListOutputParser } from './N8nItemListOutputParser';
import { N8nOutputFixingParser } from './N8nOutputFixingParser';
import { N8nStructuredOutputParser } from './N8nStructuredOutputParser';
export type N8nOutputParser =
| N8nOutputFixingParser
| N8nStructuredOutputParser
| N8nItemListOutputParser;
export { N8nOutputFixingParser, N8nItemListOutputParser, N8nStructuredOutputParser };
export async function getOptionalOutputParsers(ctx: IExecuteFunctions): Promise<N8nOutputParser[]> {
let outputParsers: N8nOutputParser[] = [];
if (ctx.getNodeParameter('hasOutputParser', 0, true) === true) {
outputParsers = (await ctx.getInputConnectionData(
NodeConnectionType.AiOutputParser,
0,
)) as N8nOutputParser[];
}
return outputParsers;
}