mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
refactor(core): Shovel around more of AI code (no-changelog) (#12218)
This commit is contained in:
parent
a8e7a05856
commit
2ce1644d01
|
@ -9,6 +9,8 @@ import type {
|
|||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';
|
||||
|
||||
import { conversationalAgentProperties } from './agents/ConversationalAgent/description';
|
||||
import { conversationalAgentExecute } from './agents/ConversationalAgent/execute';
|
||||
import { openAiFunctionsAgentProperties } from './agents/OpenAiFunctionsAgent/description';
|
||||
|
@ -21,7 +23,6 @@ import { sqlAgentAgentProperties } from './agents/SqlAgent/description';
|
|||
import { sqlAgentAgentExecute } from './agents/SqlAgent/execute';
|
||||
import { toolsAgentProperties } from './agents/ToolsAgent/description';
|
||||
import { toolsAgentExecute } from './agents/ToolsAgent/execute';
|
||||
import { promptTypeOptions, textFromPreviousNode, textInput } from '../../../utils/descriptions';
|
||||
|
||||
// Function used in the inputs expression to figure out which inputs to
|
||||
// display based on the agent type
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { SYSTEM_MESSAGE, HUMAN_MESSAGE } from './prompt';
|
||||
|
||||
export const conversationalAgentProperties: INodeProperties[] = [
|
||||
|
|
|
@ -6,14 +6,11 @@ import { CombiningOutputParser } from 'langchain/output_parsers';
|
|||
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
isChatInstance,
|
||||
getPromptInputByType,
|
||||
getConnectedTools,
|
||||
} from '../../../../../utils/helpers';
|
||||
import { getOptionalOutputParsers } from '../../../../../utils/output_parsers/N8nOutputParser';
|
||||
import { throwIfToolSchema } from '../../../../../utils/schemaParsing';
|
||||
import { getTracingConfig } from '../../../../../utils/tracing';
|
||||
import { isChatInstance, getPromptInputByType, getConnectedTools } from '@utils/helpers';
|
||||
import { getOptionalOutputParsers } from '@utils/output_parsers/N8nOutputParser';
|
||||
import { throwIfToolSchema } from '@utils/schemaParsing';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { checkForStructuredTools, extractParsedOutput } from '../utils';
|
||||
|
||||
export async function conversationalAgentExecute(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { SYSTEM_MESSAGE } from './prompt';
|
||||
|
||||
export const openAiFunctionsAgentProperties: INodeProperties[] = [
|
||||
|
|
|
@ -12,9 +12,10 @@ import {
|
|||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getConnectedTools, getPromptInputByType } from '../../../../../utils/helpers';
|
||||
import { getOptionalOutputParsers } from '../../../../../utils/output_parsers/N8nOutputParser';
|
||||
import { getTracingConfig } from '../../../../../utils/tracing';
|
||||
import { getConnectedTools, getPromptInputByType } from '@utils/helpers';
|
||||
import { getOptionalOutputParsers } from '@utils/output_parsers/N8nOutputParser';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { extractParsedOutput } from '../utils';
|
||||
|
||||
export async function openAiFunctionsAgentExecute(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { DEFAULT_STEP_EXECUTOR_HUMAN_CHAT_MESSAGE_TEMPLATE } from './prompt';
|
||||
|
||||
export const planAndExecuteAgentProperties: INodeProperties[] = [
|
||||
|
|
|
@ -10,10 +10,11 @@ import {
|
|||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getConnectedTools, getPromptInputByType } from '../../../../../utils/helpers';
|
||||
import { getOptionalOutputParsers } from '../../../../../utils/output_parsers/N8nOutputParser';
|
||||
import { throwIfToolSchema } from '../../../../../utils/schemaParsing';
|
||||
import { getTracingConfig } from '../../../../../utils/tracing';
|
||||
import { getConnectedTools, getPromptInputByType } from '@utils/helpers';
|
||||
import { getOptionalOutputParsers } from '@utils/output_parsers/N8nOutputParser';
|
||||
import { throwIfToolSchema } from '@utils/schemaParsing';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { checkForStructuredTools, extractParsedOutput } from '../utils';
|
||||
|
||||
export async function planAndExecuteAgentExecute(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { HUMAN_MESSAGE_TEMPLATE, PREFIX, SUFFIX, SUFFIX_CHAT } from './prompt';
|
||||
|
||||
export const reActAgentAgentProperties: INodeProperties[] = [
|
||||
|
|
|
@ -11,14 +11,11 @@ import {
|
|||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
getConnectedTools,
|
||||
getPromptInputByType,
|
||||
isChatInstance,
|
||||
} from '../../../../../utils/helpers';
|
||||
import { getOptionalOutputParsers } from '../../../../../utils/output_parsers/N8nOutputParser';
|
||||
import { throwIfToolSchema } from '../../../../../utils/schemaParsing';
|
||||
import { getTracingConfig } from '../../../../../utils/tracing';
|
||||
import { getConnectedTools, getPromptInputByType, isChatInstance } from '@utils/helpers';
|
||||
import { getOptionalOutputParsers } from '@utils/output_parsers/N8nOutputParser';
|
||||
import { throwIfToolSchema } from '@utils/schemaParsing';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { checkForStructuredTools, extractParsedOutput } from '../utils';
|
||||
|
||||
export async function reActAgentAgentExecute(
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { promptTypeOptions, textFromPreviousNode, textInput } from '@utils/descriptions';
|
||||
|
||||
import { SQL_PREFIX, SQL_SUFFIX } from './other/prompts';
|
||||
import {
|
||||
promptTypeOptions,
|
||||
textFromPreviousNode,
|
||||
textInput,
|
||||
} from '../../../../../utils/descriptions';
|
||||
|
||||
const dataSourceOptions: INodeProperties = {
|
||||
displayName: 'Data Source',
|
||||
|
|
|
@ -12,12 +12,13 @@ import {
|
|||
type IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getPromptInputByType, serializeChatHistory } from '@utils/helpers';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { getMysqlDataSource } from './other/handlers/mysql';
|
||||
import { getPostgresDataSource } from './other/handlers/postgres';
|
||||
import { getSqliteDataSource } from './other/handlers/sqlite';
|
||||
import { SQL_PREFIX, SQL_SUFFIX } from './other/prompts';
|
||||
import { getPromptInputByType, serializeChatHistory } from '../../../../../utils/helpers';
|
||||
import { getTracingConfig } from '../../../../../utils/tracing';
|
||||
|
||||
const parseTablesString = (tablesString: string) =>
|
||||
tablesString
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { type IExecuteFunctions } from 'n8n-workflow';
|
||||
import { DataSource } from '@n8n/typeorm';
|
||||
import { type IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
export async function getMysqlDataSource(this: IExecuteFunctions): Promise<DataSource> {
|
||||
const credentials = await this.getCredentials('mySql');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { type IExecuteFunctions } from 'n8n-workflow';
|
||||
import { DataSource } from '@n8n/typeorm';
|
||||
import { type IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
export async function getPostgresDataSource(this: IExecuteFunctions): Promise<DataSource> {
|
||||
const credentials = await this.getCredentials('postgres');
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { DataSource } from '@n8n/typeorm';
|
||||
import * as fs from 'fs';
|
||||
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
import { BINARY_ENCODING, NodeOperationError } from 'n8n-workflow';
|
||||
import * as temp from 'temp';
|
||||
import * as sqlite3 from 'sqlite3';
|
||||
import { DataSource } from '@n8n/typeorm';
|
||||
import * as temp from 'temp';
|
||||
|
||||
export async function getSqliteDataSource(
|
||||
this: IExecuteFunctions,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { SYSTEM_MESSAGE } from './prompt';
|
||||
|
||||
export const toolsAgentProperties: INodeProperties[] = [
|
||||
|
|
|
@ -14,16 +14,13 @@ import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
|||
import type { ZodObject } from 'zod';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { SYSTEM_MESSAGE } from './prompt';
|
||||
import {
|
||||
isChatInstance,
|
||||
getPromptInputByType,
|
||||
getConnectedTools,
|
||||
} from '../../../../../utils/helpers';
|
||||
import { isChatInstance, getPromptInputByType, getConnectedTools } from '@utils/helpers';
|
||||
import {
|
||||
getOptionalOutputParsers,
|
||||
type N8nOutputParser,
|
||||
} from '../../../../../utils/output_parsers/N8nOutputParser';
|
||||
} from '@utils/output_parsers/N8nOutputParser';
|
||||
|
||||
import { SYSTEM_MESSAGE } from './prompt';
|
||||
|
||||
function getOutputParserSchema(outputParser: N8nOutputParser): ZodObject<any, any, any, any> {
|
||||
const schema =
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { z } from 'zod';
|
||||
import type { BaseOutputParser } from '@langchain/core/output_parsers';
|
||||
import type { DynamicStructuredTool, Tool } from 'langchain/tools';
|
||||
import { NodeOperationError, type IExecuteFunctions, type INode } from 'n8n-workflow';
|
||||
import type { z } from 'zod';
|
||||
|
||||
type ZodObjectAny = z.ZodObject<any, any, any, any>;
|
||||
|
||||
|
|
|
@ -10,9 +10,10 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { OpenAI as OpenAIClient } from 'openai';
|
||||
|
||||
import { getConnectedTools } from '@utils/helpers';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { formatToOpenAIAssistantTool } from './utils';
|
||||
import { getConnectedTools } from '../../../utils/helpers';
|
||||
import { getTracingConfig } from '../../../utils/tracing';
|
||||
|
||||
export class OpenAiAssistant implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||
import type { OpenAIClient } from '@langchain/openai';
|
||||
import type { StructuredTool } from '@langchain/core/tools';
|
||||
import type { OpenAIClient } from '@langchain/openai';
|
||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||
|
||||
// Copied from langchain(`langchain/src/tools/convert_to_openai.ts`)
|
||||
// since these functions are not exported
|
||||
|
|
|
@ -27,16 +27,17 @@ import {
|
|||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getPromptInputByType, isChatInstance } from '../../../utils/helpers';
|
||||
import type { N8nOutputParser } from '../../../utils/output_parsers/N8nOutputParser';
|
||||
import { getOptionalOutputParsers } from '../../../utils/output_parsers/N8nOutputParser';
|
||||
import { getTemplateNoticeField } from '../../../utils/sharedFields';
|
||||
import { getTracingConfig } from '../../../utils/tracing';
|
||||
import { promptTypeOptions, textFromPreviousNode } from '@utils/descriptions';
|
||||
import { getPromptInputByType, isChatInstance } from '@utils/helpers';
|
||||
import type { N8nOutputParser } from '@utils/output_parsers/N8nOutputParser';
|
||||
import { getOptionalOutputParsers } from '@utils/output_parsers/N8nOutputParser';
|
||||
import { getTemplateNoticeField } from '@utils/sharedFields';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import {
|
||||
getCustomErrorMessage as getCustomOpenAiErrorMessage,
|
||||
isOpenAiError,
|
||||
} from '../../vendors/OpenAi/helpers/error-handling';
|
||||
import { promptTypeOptions, textFromPreviousNode } from '../../../utils/descriptions';
|
||||
|
||||
interface MessagesTemplate {
|
||||
type: string;
|
||||
|
|
|
@ -16,10 +16,10 @@ import {
|
|||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { promptTypeOptions, textFromPreviousNode } from '../../../utils/descriptions';
|
||||
import { getPromptInputByType, isChatInstance } from '../../../utils/helpers';
|
||||
import { getTemplateNoticeField } from '../../../utils/sharedFields';
|
||||
import { getTracingConfig } from '../../../utils/tracing';
|
||||
import { promptTypeOptions, textFromPreviousNode } from '@utils/descriptions';
|
||||
import { getPromptInputByType, isChatInstance } from '@utils/helpers';
|
||||
import { getTemplateNoticeField } from '@utils/sharedFields';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
const SYSTEM_PROMPT_TEMPLATE = `Use the following pieces of context to answer the users question.
|
||||
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
import type { Document } from '@langchain/core/documents';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import { PromptTemplate } from '@langchain/core/prompts';
|
||||
import type { SummarizationChainParams } from 'langchain/chains';
|
||||
import { loadSummarizationChain } from 'langchain/chains';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeTypeBaseDescription,
|
||||
|
@ -7,14 +12,10 @@ import {
|
|||
type INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { SummarizationChainParams } from 'langchain/chains';
|
||||
import { loadSummarizationChain } from 'langchain/chains';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import { PromptTemplate } from '@langchain/core/prompts';
|
||||
import { N8nJsonLoader } from '../../../../utils/N8nJsonLoader';
|
||||
import { N8nBinaryLoader } from '../../../../utils/N8nBinaryLoader';
|
||||
import { getTemplateNoticeField } from '../../../../utils/sharedFields';
|
||||
import { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
|
||||
import { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
import { getTemplateNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { REFINE_PROMPT_TEMPLATE, DEFAULT_PROMPT_TEMPLATE } from '../prompt';
|
||||
|
||||
export class ChainSummarizationV1 implements INodeType {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import { loadSummarizationChain } from 'langchain/chains';
|
||||
import type {
|
||||
INodeTypeBaseDescription,
|
||||
IExecuteFunctions,
|
||||
|
@ -7,18 +11,15 @@ import type {
|
|||
INodeTypeDescription,
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
|
||||
import { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
|
||||
import { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
import { getTemplateNoticeField } from '@utils/sharedFields';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { loadSummarizationChain } from 'langchain/chains';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import { N8nJsonLoader } from '../../../../utils/N8nJsonLoader';
|
||||
import { N8nBinaryLoader } from '../../../../utils/N8nBinaryLoader';
|
||||
import { getTemplateNoticeField } from '../../../../utils/sharedFields';
|
||||
import { REFINE_PROMPT_TEMPLATE, DEFAULT_PROMPT_TEMPLATE } from '../prompt';
|
||||
import { getChainPromptsArgs } from '../helpers';
|
||||
import { getTracingConfig } from '../../../../utils/tracing';
|
||||
import { REFINE_PROMPT_TEMPLATE, DEFAULT_PROMPT_TEMPLATE } from '../prompt';
|
||||
|
||||
function getInputs(parameters: IDataObject) {
|
||||
const chunkingMode = parameters?.chunkingMode;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import type { SummarizationChainParams } from 'langchain/chains';
|
||||
import { PromptTemplate } from '@langchain/core/prompts';
|
||||
import type { SummarizationChainParams } from 'langchain/chains';
|
||||
interface ChainTypeOptions {
|
||||
combineMapPrompt?: string;
|
||||
prompt?: string;
|
||||
|
|
|
@ -13,15 +13,12 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import type { z } from 'zod';
|
||||
|
||||
import { inputSchemaField, jsonSchemaExampleField, schemaTypeField } from '@utils/descriptions';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
import { makeZodSchemaFromAttributes } from './helpers';
|
||||
import type { AttributeDefinition } from './types';
|
||||
import {
|
||||
inputSchemaField,
|
||||
jsonSchemaExampleField,
|
||||
schemaTypeField,
|
||||
} from '../../../utils/descriptions';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '../../../utils/schemaParsing';
|
||||
import { getTracingConfig } from '../../../utils/tracing';
|
||||
|
||||
const SYSTEM_PROMPT_TEMPLATE = `You are an expert extraction algorithm.
|
||||
Only extract relevant information from the text.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { z } from 'zod';
|
||||
|
||||
import type { AttributeDefinition } from './types';
|
||||
|
||||
function makeAttributeSchema(attributeDefinition: AttributeDefinition, required: boolean = true) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import type { IDataObject, IExecuteFunctions } from 'n8n-workflow/src';
|
||||
import get from 'lodash/get';
|
||||
|
||||
import { FakeLLM, FakeListChatModel } from '@langchain/core/utils/testing';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import { InformationExtractor } from '../InformationExtractor.node';
|
||||
import { FakeLLM, FakeListChatModel } from '@langchain/core/utils/testing';
|
||||
import get from 'lodash/get';
|
||||
import type { IDataObject, IExecuteFunctions } from 'n8n-workflow/src';
|
||||
|
||||
import { makeZodSchemaFromAttributes } from '../helpers';
|
||||
import { InformationExtractor } from '../InformationExtractor.node';
|
||||
import type { AttributeDefinition } from '../types';
|
||||
|
||||
const mockPersonAttributes: AttributeDefinition[] = [
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import { HumanMessage } from '@langchain/core/messages';
|
||||
import { SystemMessagePromptTemplate, ChatPromptTemplate } from '@langchain/core/prompts';
|
||||
import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers';
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
|
@ -6,15 +11,9 @@ import type {
|
|||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import { HumanMessage } from '@langchain/core/messages';
|
||||
import { SystemMessagePromptTemplate, ChatPromptTemplate } from '@langchain/core/prompts';
|
||||
import { OutputFixingParser, StructuredOutputParser } from 'langchain/output_parsers';
|
||||
import { z } from 'zod';
|
||||
import { getTracingConfig } from '../../../utils/tracing';
|
||||
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
const DEFAULT_SYSTEM_PROMPT_TEMPLATE =
|
||||
'You are highly intelligent and accurate sentiment analyzer. Analyze the sentiment of the provided text. Categorize it into one of the following: {categories}. Use the provided formatting instructions. Only output the JSON.';
|
||||
|
|
|
@ -13,7 +13,7 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { getTracingConfig } from '../../../utils/tracing';
|
||||
import { getTracingConfig } from '@utils/tracing';
|
||||
|
||||
const SYSTEM_PROMPT_TEMPLATE =
|
||||
"Please classify the text provided by the user into one of the following categories: {categories}, and use the provided formatting instructions below. Don't explain, and only output the json.";
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { Tool } from '@langchain/core/tools';
|
||||
import { makeResolverFromLegacyOptions } from '@n8n/vm2';
|
||||
import { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';
|
||||
import { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';
|
||||
import { standardizeOutput } from 'n8n-nodes-base/dist/nodes/Code/utils';
|
||||
import { NodeOperationError, NodeConnectionType } from 'n8n-workflow';
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
|
@ -12,12 +17,7 @@ import type {
|
|||
|
||||
// TODO: Add support for execute function. Got already started but got commented out
|
||||
|
||||
import { getSandboxContext } from 'n8n-nodes-base/dist/nodes/Code/Sandbox';
|
||||
import { JavaScriptSandbox } from 'n8n-nodes-base/dist/nodes/Code/JavaScriptSandbox';
|
||||
import { standardizeOutput } from 'n8n-nodes-base/dist/nodes/Code/utils';
|
||||
import type { Tool } from '@langchain/core/tools';
|
||||
import { makeResolverFromLegacyOptions } from '@n8n/vm2';
|
||||
import { logWrapper } from '../../utils/logWrapper';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
|
||||
const { NODE_FUNCTION_ALLOW_BUILTIN: builtIn, NODE_FUNCTION_ALLOW_EXTERNAL: external } =
|
||||
process.env;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,11 +8,9 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { N8nBinaryLoader } from '../../../utils/N8nBinaryLoader';
|
||||
import { getConnectionHintNoticeField, metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
|
||||
import { getConnectionHintNoticeField, metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
// Dependencies needed underneath the hood for the loaders. We add them
|
||||
// here only to track where what dependency is sued
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,10 +8,9 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { N8nBinaryLoader } from '../../../utils/N8nBinaryLoader';
|
||||
import { metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { N8nBinaryLoader } from '@utils/N8nBinaryLoader';
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
// Dependencies needed underneath the hood for the loaders. We add them
|
||||
// here only to track where what dependency is sued
|
||||
|
@ -18,7 +18,7 @@ import { metadataFilterField } from '../../../utils/sharedFields';
|
|||
import 'mammoth'; // for docx
|
||||
import 'epub2'; // for epub
|
||||
import 'pdf-parse'; // for pdf
|
||||
import { N8nJsonLoader } from '../../../utils/N8nJsonLoader';
|
||||
import { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
|
||||
export class DocumentDefaultDataLoader implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { GithubRepoLoader } from '@langchain/community/document_loaders/web/github';
|
||||
import type { CharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,10 +8,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { GithubRepoLoader } from '@langchain/community/document_loaders/web/github';
|
||||
import type { CharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class DocumentGithubLoader implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,10 +8,9 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { TextSplitter } from '@langchain/textsplitters';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { N8nJsonLoader } from '../../../utils/N8nJsonLoader';
|
||||
import { getConnectionHintNoticeField, metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
import { getConnectionHintNoticeField, metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
export class DocumentJsonInputLoader implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -8,8 +8,8 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class EmbeddingsAwsBedrock implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { OpenAIEmbeddings } from '@langchain/openai';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,9 +8,8 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { OpenAIEmbeddings } from '@langchain/openai';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class EmbeddingsAzureOpenAi implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { CohereEmbeddings } from '@langchain/cohere';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { CohereEmbeddings } from '@langchain/cohere';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class EmbeddingsCohere implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { GoogleGenerativeAIEmbeddings } from '@langchain/google-genai';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,10 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { GoogleGenerativeAIEmbeddings } from '@langchain/google-genai';
|
||||
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class EmbeddingsGoogleGemini implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { HuggingFaceInferenceEmbeddings } from '@langchain/community/embeddings/hf';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { HuggingFaceInferenceEmbeddings } from '@langchain/community/embeddings/hf';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class EmbeddingsHuggingFaceInference implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { MistralAIEmbeddingsParams } from '@langchain/mistralai';
|
||||
import { MistralAIEmbeddings } from '@langchain/mistralai';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,10 +8,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import type { MistralAIEmbeddingsParams } from '@langchain/mistralai';
|
||||
import { MistralAIEmbeddings } from '@langchain/mistralai';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class EmbeddingsMistralCloud implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { OllamaEmbeddings } from '@langchain/ollama';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,10 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { OllamaEmbeddings } from '@langchain/ollama';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { ollamaDescription, ollamaModel } from '../../llms/LMOllama/description';
|
||||
|
||||
export class EmbeddingsOllama implements INodeType {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { OpenAIEmbeddings } from '@langchain/openai';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,11 +8,10 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { ClientOptions } from 'openai';
|
||||
import { OpenAIEmbeddings } from '@langchain/openai';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
const modelParameter: INodeProperties = {
|
||||
displayName: 'Model',
|
||||
|
|
|
@ -12,9 +12,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
const modelField: INodeProperties = {
|
||||
displayName: 'Model',
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
|
||||
import type { ChatOllamaInput } from '@langchain/ollama';
|
||||
import { ChatOllama } from '@langchain/ollama';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,12 +10,11 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { ChatOllamaInput } from '@langchain/ollama';
|
||||
import { ChatOllama } from '@langchain/ollama';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { ollamaModel, ollamaOptions, ollamaDescription } from '../LMOllama/description';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmChatOllama implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -9,7 +9,8 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { openAiFailedAttemptHandler } from '../../vendors/OpenAi/helpers/error-handling';
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { Cohere } from '@langchain/cohere';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,10 +8,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { Cohere } from '@langchain/cohere';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmCohere implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
|
||||
import { Ollama } from '@langchain/community/llms/ollama';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,11 +9,11 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { Ollama } from '@langchain/community/llms/ollama';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { ollamaDescription, ollamaModel, ollamaOptions } from './description';
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmOllama implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { OpenAI, type ClientOptions } from '@langchain/openai';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import type {
|
||||
INodeType,
|
||||
|
@ -8,9 +9,8 @@ import type {
|
|||
ILoadOptionsFunctions,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { OpenAI, type ClientOptions } from '@langchain/openai';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
type LmOpenAiOptions = {
|
||||
baseURL?: string;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { HuggingFaceInference } from '@langchain/community/llms/hf';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,10 +8,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { HuggingFaceInference } from '@langchain/community/llms/hf';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmOpenHuggingFaceInference implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -8,9 +8,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmChatAwsBedrock implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { ChatOpenAI } from '@langchain/openai';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,10 +8,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { ChatOpenAI } from '@langchain/openai';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmChatAzureOpenAi implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { SafetySetting } from '@google/generative-ai';
|
||||
import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,12 +8,12 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
|
||||
import type { SafetySetting } from '@google/generative-ai';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { additionalOptions } from '../gemini-common/additional-options';
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmChatGoogleGemini implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { SafetySetting } from '@google/generative-ai';
|
||||
import { ProjectsClient } from '@google-cloud/resource-manager';
|
||||
import { ChatVertexAI } from '@langchain/google-vertexai';
|
||||
import { formatPrivateKey } from 'n8n-nodes-base/dist/utils/utilities';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -9,15 +13,13 @@ import {
|
|||
type JsonObject,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { ChatVertexAI } from '@langchain/google-vertexai';
|
||||
import type { SafetySetting } from '@google/generative-ai';
|
||||
import { ProjectsClient } from '@google-cloud/resource-manager';
|
||||
import { formatPrivateKey } from 'n8n-nodes-base/dist/utils/utilities';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { additionalOptions } from '../gemini-common/additional-options';
|
||||
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeErrorFromStatus } from './error-handling';
|
||||
import { additionalOptions } from '../gemini-common/additional-options';
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmChatGoogleVertex implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { ChatGroq } from '@langchain/groq';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,10 +8,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { ChatGroq } from '@langchain/groq';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmChatGroq implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
|
||||
import type { ChatMistralAIInput } from '@langchain/mistralai';
|
||||
import { ChatMistralAI } from '@langchain/mistralai';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,11 +10,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { ChatMistralAIInput } from '@langchain/mistralai';
|
||||
import { ChatMistralAI } from '@langchain/mistralai';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { makeN8nLlmFailedAttemptHandler } from '../n8nLlmFailedAttemptHandler';
|
||||
import { N8nLlmTracing } from '../N8nLlmTracing';
|
||||
|
||||
export class LmChatMistralCloud implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -9,11 +9,11 @@ import type {
|
|||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
import type { LLMResult } from '@langchain/core/outputs';
|
||||
import { encodingForModel } from '@langchain/core/utils/tiktoken';
|
||||
import type { IDataObject, ISupplyDataFunctions, JsonObject } from 'n8n-workflow';
|
||||
import { pick } from 'lodash';
|
||||
import type { IDataObject, ISupplyDataFunctions, JsonObject } from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { logAiEvent } from '../../utils/helpers';
|
||||
import { logAiEvent } from '@utils/helpers';
|
||||
|
||||
type TokensUsageParser = (llmOutput: LLMResult['llmOutput']) => {
|
||||
completionTokens: number;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { HarmBlockThreshold, HarmCategory } from '@google/generative-ai';
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { harmCategories, harmThresholds } from './safety-options';
|
||||
|
||||
export const additionalOptions: INodeProperties = {
|
||||
|
|
|
@ -9,9 +9,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getSessionId } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
|
||||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type IDataObject,
|
||||
|
@ -7,8 +9,6 @@ import {
|
|||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
|
||||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
|
||||
function simplifyMessages(messages: BaseMessage[]) {
|
||||
const chunkedMessages = [];
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
|
||||
import { AIMessage, SystemMessage, HumanMessage, type BaseMessage } from '@langchain/core/messages';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import type {
|
||||
IDataObject,
|
||||
|
@ -7,8 +9,6 @@ import type {
|
|||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
|
||||
import { AIMessage, SystemMessage, HumanMessage, type BaseMessage } from '@langchain/core/messages';
|
||||
|
||||
type MessageRole = 'ai' | 'system' | 'user';
|
||||
interface MessageRecord {
|
||||
|
|
|
@ -8,9 +8,10 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getSessionId } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';
|
||||
|
||||
export class MemoryMotorhead implements INodeType {
|
||||
|
|
|
@ -13,9 +13,10 @@ import type {
|
|||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
import type pg from 'pg';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getSessionId } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
|
|
|
@ -13,9 +13,10 @@ import {
|
|||
import type { RedisClientOptions } from 'redis';
|
||||
import { createClient } from 'redis';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getSessionId } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
|
|
|
@ -10,9 +10,10 @@ import type {
|
|||
SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getSessionId } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import {
|
||||
sessionIdOption,
|
||||
sessionKeyProperty,
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { BaseChatMemory } from '@langchain/community/dist/memory/chat_memory';
|
||||
import { ZepMemory } from '@langchain/community/memory/zep';
|
||||
import { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';
|
||||
import type { InputValues, MemoryVariables } from '@langchain/core/memory';
|
||||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type ISupplyDataFunctions,
|
||||
|
@ -7,16 +12,12 @@ import {
|
|||
type SupplyData,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { ZepMemory } from '@langchain/community/memory/zep';
|
||||
import { ZepCloudMemory } from '@langchain/community/memory/zep_cloud';
|
||||
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { getSessionId } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { expressionSessionKeyProperty, sessionIdOption, sessionKeyProperty } from '../descriptions';
|
||||
import { getSessionId } from '../../../utils/helpers';
|
||||
import type { BaseChatMemory } from '@langchain/community/dist/memory/chat_memory';
|
||||
import type { InputValues, MemoryVariables } from '@langchain/core/memory';
|
||||
import type { BaseMessage } from '@langchain/core/messages';
|
||||
|
||||
// Extend ZepCloudMemory to trim white space in messages.
|
||||
class WhiteSpaceTrimmedZepCloudMemory extends ZepCloudMemory {
|
||||
|
|
|
@ -8,12 +8,13 @@ import type {
|
|||
SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { NAIVE_FIX_PROMPT } from './prompt';
|
||||
import {
|
||||
N8nOutputFixingParser,
|
||||
type N8nStructuredOutputParser,
|
||||
} from '../../../utils/output_parsers/N8nOutputParser';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
} from '@utils/output_parsers/N8nOutputParser';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import { NAIVE_FIX_PROMPT } from './prompt';
|
||||
|
||||
export class OutputParserAutofixing implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -11,7 +11,8 @@ import { ApplicationError, NodeConnectionType, NodeOperationError } from 'n8n-wo
|
|||
import type {
|
||||
N8nOutputFixingParser,
|
||||
N8nStructuredOutputParser,
|
||||
} from '../../../../utils/output_parsers/N8nOutputParser';
|
||||
} from '@utils/output_parsers/N8nOutputParser';
|
||||
|
||||
import { OutputParserAutofixing } from '../OutputParserAutofixing.node';
|
||||
import { NAIVE_FIX_PROMPT } from '../prompt';
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { N8nItemListOutputParser } from '../../../utils/output_parsers/N8nItemListOutputParser';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { N8nItemListOutputParser } from '@utils/output_parsers/N8nItemListOutputParser';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class OutputParserItemList implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -6,7 +6,8 @@ import {
|
|||
type IWorkflowDataProxyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { N8nItemListOutputParser } from '../../../../utils/output_parsers/N8nItemListOutputParser';
|
||||
import { N8nItemListOutputParser } from '@utils/output_parsers/N8nItemListOutputParser';
|
||||
|
||||
import { OutputParserItemList } from '../OutputParserItemList.node';
|
||||
|
||||
describe('OutputParserItemList', () => {
|
||||
|
|
|
@ -10,14 +10,10 @@ import {
|
|||
} from 'n8n-workflow';
|
||||
import type { z } from 'zod';
|
||||
|
||||
import {
|
||||
inputSchemaField,
|
||||
jsonSchemaExampleField,
|
||||
schemaTypeField,
|
||||
} from '../../../utils/descriptions';
|
||||
import { N8nStructuredOutputParser } from '../../../utils/output_parsers/N8nOutputParser';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '../../../utils/schemaParsing';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { inputSchemaField, jsonSchemaExampleField, schemaTypeField } from '@utils/descriptions';
|
||||
import { N8nStructuredOutputParser } from '@utils/output_parsers/N8nOutputParser';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class OutputParserStructured implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -7,7 +7,8 @@ import {
|
|||
type IWorkflowDataProxyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { N8nStructuredOutputParser } from '../../../../utils/output_parsers/N8nStructuredOutputParser';
|
||||
import type { N8nStructuredOutputParser } from '@utils/output_parsers/N8nStructuredOutputParser';
|
||||
|
||||
import { OutputParserStructured } from '../OutputParserStructured.node';
|
||||
|
||||
describe('OutputParserStructured', () => {
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { BaseRetriever } from '@langchain/core/retrievers';
|
||||
import { ContextualCompressionRetriever } from 'langchain/retrievers/contextual_compression';
|
||||
import { LLMChainExtractor } from 'langchain/retrievers/document_compressors/chain_extract';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,12 +12,7 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { ContextualCompressionRetriever } from 'langchain/retrievers/contextual_compression';
|
||||
import { LLMChainExtractor } from 'langchain/retrievers/document_compressors/chain_extract';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { BaseRetriever } from '@langchain/core/retrievers';
|
||||
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
|
||||
export class RetrieverContextualCompression implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { BaseRetriever } from '@langchain/core/retrievers';
|
||||
import { MultiQueryRetriever } from 'langchain/retrievers/multi_query';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -7,11 +11,7 @@ import {
|
|||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { MultiQueryRetriever } from 'langchain/retrievers/multi_query';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { BaseRetriever } from '@langchain/core/retrievers';
|
||||
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
|
||||
export class RetrieverMultiQuery implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,8 +7,8 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
|
||||
export class RetrieverVectorStore implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { CallbackManagerForRetrieverRun } from '@langchain/core/callbacks/manager';
|
||||
import { Document } from '@langchain/core/documents';
|
||||
import { BaseRetriever, type BaseRetrieverInput } from '@langchain/core/retrievers';
|
||||
import type { SetField, SetNodeOptions } from 'n8n-nodes-base/dist/nodes/Set/v2/helpers/interfaces';
|
||||
import * as manual from 'n8n-nodes-base/dist/nodes/Set/v2/manual.mode';
|
||||
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
import type {
|
||||
IDataObject,
|
||||
|
@ -13,13 +18,7 @@ import type {
|
|||
ExecuteWorkflowData,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import { BaseRetriever, type BaseRetrieverInput } from '@langchain/core/retrievers';
|
||||
import { Document } from '@langchain/core/documents';
|
||||
|
||||
import type { SetField, SetNodeOptions } from 'n8n-nodes-base/dist/nodes/Set/v2/helpers/interfaces';
|
||||
import * as manual from 'n8n-nodes-base/dist/nodes/Set/v2/manual.mode';
|
||||
import type { CallbackManagerForRetrieverRun } from '@langchain/core/callbacks/manager';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
|
||||
function objectToString(obj: Record<string, string> | IDataObject, level = 0) {
|
||||
let result = '';
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { CharacterTextSplitterParams } from '@langchain/textsplitters';
|
||||
import { CharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,10 +8,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import type { CharacterTextSplitterParams } from '@langchain/textsplitters';
|
||||
import { CharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class TextSplitterCharacterTextSplitter implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type {
|
||||
RecursiveCharacterTextSplitterParams,
|
||||
SupportedTextSplitterLanguage,
|
||||
} from '@langchain/textsplitters';
|
||||
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,13 +11,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import type {
|
||||
RecursiveCharacterTextSplitterParams,
|
||||
SupportedTextSplitterLanguage,
|
||||
} from '@langchain/textsplitters';
|
||||
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
const supportedLanguages: SupportedTextSplitterLanguage[] = [
|
||||
'cpp',
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { TokenTextSplitter } from '@langchain/textsplitters';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { TokenTextSplitter } from '@langchain/textsplitters';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class TextSplitterTokenSplitter implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { Calculator } from '@langchain/community/tools/calculator';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { Calculator } from '@langchain/community/tools/calculator';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class ToolCalculator implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -15,14 +15,11 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { jsonParse, NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { inputSchemaField, jsonSchemaExampleField, schemaTypeField } from '@utils/descriptions';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import type { DynamicZodObject } from '../../../types/zod.types';
|
||||
import {
|
||||
inputSchemaField,
|
||||
jsonSchemaExampleField,
|
||||
schemaTypeField,
|
||||
} from '../../../utils/descriptions';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '../../../utils/schemaParsing';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
export class ToolCode implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { DynamicTool } from '@langchain/core/tools';
|
||||
import type {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
|
@ -9,19 +10,8 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeOperationError, tryToParseAlphanumericString } from 'n8n-workflow';
|
||||
|
||||
import { DynamicTool } from '@langchain/core/tools';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { N8nTool } from '../../../utils/N8nTool';
|
||||
import {
|
||||
configureHttpRequestFunction,
|
||||
configureResponseOptimizer,
|
||||
extractParametersFromText,
|
||||
prepareToolDescription,
|
||||
configureToolFunction,
|
||||
updateParametersAndOptions,
|
||||
makeToolInputSchema,
|
||||
} from './utils';
|
||||
import { N8nTool } from '@utils/N8nTool';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import {
|
||||
authenticationProperties,
|
||||
|
@ -31,8 +21,16 @@ import {
|
|||
placeholderDefinitionsCollection,
|
||||
specifyBySelector,
|
||||
} from './descriptions';
|
||||
|
||||
import type { PlaceholderDefinition, ToolParameter } from './interfaces';
|
||||
import {
|
||||
configureHttpRequestFunction,
|
||||
configureResponseOptimizer,
|
||||
extractParametersFromText,
|
||||
prepareToolDescription,
|
||||
configureToolFunction,
|
||||
updateParametersAndOptions,
|
||||
makeToolInputSchema,
|
||||
} from './utils';
|
||||
|
||||
export class ToolHttpRequest implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -2,7 +2,8 @@ import { mock } from 'jest-mock-extended';
|
|||
import type { IExecuteFunctions, INode } from 'n8n-workflow';
|
||||
import { jsonParse } from 'n8n-workflow';
|
||||
|
||||
import type { N8nTool } from '../../../../utils/N8nTool';
|
||||
import type { N8nTool } from '@utils/N8nTool';
|
||||
|
||||
import { ToolHttpRequest } from '../ToolHttpRequest.node';
|
||||
|
||||
describe('ToolHttpRequest', () => {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { SerpAPI } from '@langchain/community/tools/serpapi';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { SerpAPI } from '@langchain/community/tools/serpapi';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class ToolSerpApi implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import { VectorDBQAChain } from 'langchain/chains';
|
||||
import { VectorStoreQATool } from 'langchain/tools';
|
||||
import type {
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
|
@ -6,12 +10,8 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType } from 'n8n-workflow';
|
||||
|
||||
import { VectorStoreQATool } from 'langchain/tools';
|
||||
import type { VectorStore } from '@langchain/core/vectorstores';
|
||||
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
|
||||
import { VectorDBQAChain } from 'langchain/chains';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class ToolVectorStore implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { WikipediaQueryRun } from '@langchain/community/tools/wikipedia_query_run';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { WikipediaQueryRun } from '@langchain/community/tools/wikipedia_query_run';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class ToolWikipedia implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,9 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
export class ToolWolframAlpha implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -21,14 +21,11 @@ import type {
|
|||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeOperationError, jsonParse } from 'n8n-workflow';
|
||||
|
||||
import { jsonSchemaExampleField, schemaTypeField, inputSchemaField } from '@utils/descriptions';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '@utils/schemaParsing';
|
||||
import { getConnectionHintNoticeField } from '@utils/sharedFields';
|
||||
|
||||
import type { DynamicZodObject } from '../../../types/zod.types';
|
||||
import {
|
||||
jsonSchemaExampleField,
|
||||
schemaTypeField,
|
||||
inputSchemaField,
|
||||
} from '../../../utils/descriptions';
|
||||
import { convertJsonSchemaToZod, generateSchema } from '../../../utils/schemaParsing';
|
||||
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
|
||||
|
||||
export class ToolWorkflow implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import type { ICredentialDataDecryptedObject, IWebhookFunctions } from 'n8n-workflow';
|
||||
import basicAuth from 'basic-auth';
|
||||
import type { ICredentialDataDecryptedObject, IWebhookFunctions } from 'n8n-workflow';
|
||||
|
||||
import { ChatTriggerAuthorizationError } from './error';
|
||||
import type { AuthenticationChatOption } from './types';
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { createVectorStoreNode } from '../shared/createVectorStoreNode';
|
||||
import { MemoryVectorStoreManager } from '../shared/MemoryVectorStoreManager';
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { Document } from 'langchain/document';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeExecutionData,
|
||||
|
@ -6,11 +8,11 @@ import {
|
|||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import type { Document } from 'langchain/document';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { N8nJsonLoader } from '../../../utils/N8nJsonLoader';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
|
||||
import { MemoryVectorStoreManager } from '../shared/MemoryVectorStoreManager';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
|
||||
// This node is deprecated. Use VectorStoreInMemory instead.
|
||||
export class VectorStoreInMemoryInsert implements INodeType {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -6,9 +7,10 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
|
||||
import { MemoryVectorStoreManager } from '../shared/MemoryVectorStoreManager';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
|
||||
// This node is deprecated. Use VectorStoreInMemory instead.
|
||||
export class VectorStoreInMemoryLoad implements INodeType {
|
||||
|
|
|
@ -9,7 +9,8 @@ import { configurePostgres } from 'n8n-nodes-base/dist/nodes/Postgres/v2/transpo
|
|||
import type { INodeProperties } from 'n8n-workflow';
|
||||
import type pg from 'pg';
|
||||
|
||||
import { metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { createVectorStoreNode } from '../shared/createVectorStoreNode';
|
||||
|
||||
type CollectionOptions = {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { NodeOperationError, type INodeProperties } from 'n8n-workflow';
|
||||
import type { PineconeStoreParams } from '@langchain/pinecone';
|
||||
import { PineconeStore } from '@langchain/pinecone';
|
||||
import { Pinecone } from '@pinecone-database/pinecone';
|
||||
import { NodeOperationError, type INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { createVectorStoreNode } from '../shared/createVectorStoreNode';
|
||||
import { metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { pineconeIndexRLC } from '../shared/descriptions';
|
||||
import { pineconeIndexSearch } from '../shared/methods/listSearch';
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
import type { Document } from '@langchain/core/documents';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import { PineconeStore } from '@langchain/pinecone';
|
||||
import { Pinecone } from '@pinecone-database/pinecone';
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type INodeType,
|
||||
|
@ -5,15 +9,12 @@ import {
|
|||
type INodeExecutionData,
|
||||
NodeConnectionType,
|
||||
} from 'n8n-workflow';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
|
||||
import { PineconeStore } from '@langchain/pinecone';
|
||||
import { Pinecone } from '@pinecone-database/pinecone';
|
||||
import type { N8nJsonLoader } from '../../../utils/N8nJsonLoader';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
|
||||
import { pineconeIndexRLC } from '../shared/descriptions';
|
||||
import { pineconeIndexSearch } from '../shared/methods/listSearch';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
|
||||
// This node is deprecated. Use VectorStorePinecone instead.
|
||||
export class VectorStorePineconeInsert implements INodeType {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { PineconeStoreParams } from '@langchain/pinecone';
|
||||
import { PineconeStore } from '@langchain/pinecone';
|
||||
import { Pinecone } from '@pinecone-database/pinecone';
|
||||
import {
|
||||
NodeConnectionType,
|
||||
type INodeType,
|
||||
|
@ -5,14 +9,11 @@ import {
|
|||
type ISupplyDataFunctions,
|
||||
type SupplyData,
|
||||
} from 'n8n-workflow';
|
||||
import type { PineconeStoreParams } from '@langchain/pinecone';
|
||||
import { PineconeStore } from '@langchain/pinecone';
|
||||
import { Pinecone } from '@pinecone-database/pinecone';
|
||||
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { getMetadataFiltersValues } from '../../../utils/helpers';
|
||||
import { getMetadataFiltersValues } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { pineconeIndexRLC } from '../shared/descriptions';
|
||||
import { pineconeIndexSearch } from '../shared/methods/listSearch';
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import type { IDataObject, INodeProperties } from 'n8n-workflow';
|
||||
import type { Callbacks } from '@langchain/core/callbacks/manager';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { QdrantLibArgs } from '@langchain/qdrant';
|
||||
import { QdrantVectorStore } from '@langchain/qdrant';
|
||||
import type { Schemas as QdrantSchemas } from '@qdrant/js-client-rest';
|
||||
import type { IDataObject, INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { createVectorStoreNode } from '../shared/createVectorStoreNode';
|
||||
import { qdrantCollectionRLC } from '../shared/descriptions';
|
||||
import { qdrantCollectionsSearch } from '../shared/methods/listSearch';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { Callbacks } from '@langchain/core/callbacks/manager';
|
||||
|
||||
class ExtendedQdrantVectorStore extends QdrantVectorStore {
|
||||
private static defaultFilter: IDataObject = {};
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { NodeOperationError, type INodeProperties } from 'n8n-workflow';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import { NodeOperationError, type INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { createVectorStoreNode } from '../shared/createVectorStoreNode';
|
||||
import { metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { supabaseTableNameRLC } from '../shared/descriptions';
|
||||
import { supabaseTableNameSearch } from '../shared/methods/listSearch';
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
import { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import {
|
||||
type IExecuteFunctions,
|
||||
type INodeType,
|
||||
|
@ -5,15 +9,12 @@ import {
|
|||
type INodeExecutionData,
|
||||
NodeConnectionType,
|
||||
} from 'n8n-workflow';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import type { Document } from '@langchain/core/documents';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';
|
||||
|
||||
import type { N8nJsonLoader } from '../../../utils/N8nJsonLoader';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
import type { N8nJsonLoader } from '@utils/N8nJsonLoader';
|
||||
|
||||
import { supabaseTableNameRLC } from '../shared/descriptions';
|
||||
import { supabaseTableNameSearch } from '../shared/methods/listSearch';
|
||||
import { processDocuments } from '../shared/processDocuments';
|
||||
|
||||
// This node is deprecated. Use VectorStoreSupabase instead.
|
||||
export class VectorStoreSupabaseInsert implements INodeType {
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
import type { SupabaseLibArgs } from '@langchain/community/vectorstores/supabase';
|
||||
import { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import {
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
|
@ -5,13 +9,11 @@ import {
|
|||
type SupplyData,
|
||||
NodeConnectionType,
|
||||
} from 'n8n-workflow';
|
||||
import type { Embeddings } from '@langchain/core/embeddings';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import type { SupabaseLibArgs } from '@langchain/community/vectorstores/supabase';
|
||||
import { SupabaseVectorStore } from '@langchain/community/vectorstores/supabase';
|
||||
import { logWrapper } from '../../../utils/logWrapper';
|
||||
import { metadataFilterField } from '../../../utils/sharedFields';
|
||||
import { getMetadataFiltersValues } from '../../../utils/helpers';
|
||||
|
||||
import { getMetadataFiltersValues } from '@utils/helpers';
|
||||
import { logWrapper } from '@utils/logWrapper';
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { supabaseTableNameRLC } from '../shared/descriptions';
|
||||
import { supabaseTableNameSearch } from '../shared/methods/listSearch';
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import type { IDataObject, INodeProperties } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
import type { IZepConfig } from '@langchain/community/vectorstores/zep';
|
||||
import { ZepVectorStore } from '@langchain/community/vectorstores/zep';
|
||||
import type { IDataObject, INodeProperties } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { metadataFilterField } from '@utils/sharedFields';
|
||||
|
||||
import { createVectorStoreNode } from '../shared/createVectorStoreNode';
|
||||
import { metadataFilterField } from '../../../utils/sharedFields';
|
||||
|
||||
const embeddingDimensions: INodeProperties = {
|
||||
displayName: 'Embedding Dimensions',
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue