Skip to content

Commit

Permalink
feat(core): Upgrade all langchain related dependencies (#9504)
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
  • Loading branch information
netroy and OlegIvaniv authored May 24, 2024
1 parent 6ea8607 commit a77e8dd
Show file tree
Hide file tree
Showing 18 changed files with 996 additions and 937 deletions.
8 changes: 4 additions & 4 deletions cypress/e2e/39-projects.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ describe('Projects', () => {
});

projects.getMenuItems().last().click();
cy.intercept('GET', '/rest/credentials*').as('credentialsList');
cy.intercept('GET', '/rest/credentials*').as('credentialsListProjectId');
projects.getProjectTabCredentials().click();
cy.wait('@credentialsList').then((interception) => {
cy.wait('@credentialsListProjectId').then((interception) => {
const url = new URL(interception.request.url);
const queryParams = new URLSearchParams(url.search);
const filter = queryParams.get('filter');
Expand All @@ -150,9 +150,9 @@ describe('Projects', () => {
projects.getHomeButton().click();
workflowsPage.getters.workflowCards().should('have.length', 2);

cy.intercept('GET', '/rest/credentials*').as('credentialsList');
cy.intercept('GET', '/rest/credentials*').as('credentialsListFilterless');
projects.getProjectTabCredentials().click();
cy.wait('@credentialsList').then((interception) => {
cy.wait('@credentialsListFilterless').then((interception) => {
expect(interception.request.url).not.to.contain('filter');
});

Expand Down
6 changes: 6 additions & 0 deletions packages/@n8n/nodes-langchain/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,11 @@ module.exports = {
'n8n-nodes-base/node-param-type-options-password-missing': 'error',
},
},
{
files: ['**/*.test.ts', '**/test/**/*.ts'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from 'n8n-workflow';

import { AgentExecutor, ChatAgent, ZeroShotAgent } from 'langchain/agents';
import type { BaseLanguageModel } from 'langchain/base_language';
import type { BaseLanguageModel } from '@langchain/core/language_models/base';
import type { BaseOutputParser } from '@langchain/core/output_parsers';
import { PromptTemplate } from '@langchain/core/prompts';
import { CombiningOutputParser } from 'langchain/output_parsers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type {
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/text_splitter';
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type SupplyData,
} from 'n8n-workflow';

import type { TextSplitter } from 'langchain/text_splitter';
import type { TextSplitter } from '@langchain/textsplitters';

import { logWrapper } from '../../../utils/logWrapper';
import { N8nBinaryLoader } from '../../../utils/N8nBinaryLoader';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type SupplyData,
} from 'n8n-workflow';

import type { TextSplitter } from 'langchain/text_splitter';
import type { TextSplitter } from '@langchain/textsplitters';
import { logWrapper } from '../../../utils/logWrapper';
import { N8nBinaryLoader } from '../../../utils/N8nBinaryLoader';
import { metadataFilterField } from '../../../utils/sharedFields';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
type INodeTypeDescription,
type SupplyData,
} from 'n8n-workflow';
import { GithubRepoLoader } from 'langchain/document_loaders/web/github';
import type { CharacterTextSplitter } from 'langchain/text_splitter';
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';

Expand Down Expand Up @@ -116,7 +116,9 @@ export class DocumentGithubLoader implements INodeType {
accessToken: (credentials.accessToken as string) || '',
});

const loadedDocs = textSplitter ? await docs.loadAndSplit(textSplitter) : await docs.load();
const loadedDocs = textSplitter
? await textSplitter.splitDocuments(await docs.load())
: await docs.load();

return {
response: logWrapper(loadedDocs, this),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type SupplyData,
} from 'n8n-workflow';

import type { TextSplitter } from 'langchain/text_splitter';
import type { TextSplitter } from '@langchain/textsplitters';
import { logWrapper } from '../../../utils/logWrapper';
import { N8nJsonLoader } from '../../../utils/N8nJsonLoader';
import { getConnectionHintNoticeField, metadataFilterField } from '../../../utils/sharedFields';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
type INodeTypeDescription,
type SupplyData,
} from 'n8n-workflow';
import type { CharacterTextSplitterParams } from 'langchain/text_splitter';
import { CharacterTextSplitter } from 'langchain/text_splitter';
import type { CharacterTextSplitterParams } from '@langchain/textsplitters';
import { CharacterTextSplitter } from '@langchain/textsplitters';
import { logWrapper } from '../../../utils/logWrapper';
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
import type {
RecursiveCharacterTextSplitterParams,
SupportedTextSplitterLanguage,
} from 'langchain/text_splitter';
import { RecursiveCharacterTextSplitter } from 'langchain/text_splitter';
} from '@langchain/textsplitters';
import { RecursiveCharacterTextSplitter } from '@langchain/textsplitters';
import { logWrapper } from '../../../utils/logWrapper';
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type INodeTypeDescription,
type SupplyData,
} from 'n8n-workflow';
import { TokenTextSplitter } from 'langchain/text_splitter';
import { TokenTextSplitter } from '@langchain/textsplitters';
import { logWrapper } from '../../../utils/logWrapper';
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';

Expand Down
59 changes: 29 additions & 30 deletions packages/@n8n/nodes-langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,60 +120,59 @@
]
},
"devDependencies": {
"@aws-sdk/types": "3.357.0",
"@aws-sdk/types": "^3.535.0",
"@types/basic-auth": "^1.1.3",
"@types/express": "^4.17.21",
"@types/html-to-text": "^9.0.1",
"@types/json-schema": "^7.0.15",
"@types/temp": "^0.9.1",
"eslint-plugin-n8n-nodes-base": "^1.16.0",
"n8n-core": "workspace:*"
},
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "3.549.0",
"@aws-sdk/credential-provider-node": "3.549.0",
"@aws-sdk/client-bedrock-runtime": "3.535.0",
"@aws-sdk/credential-provider-node": "3.535.0",
"@getzep/zep-js": "0.9.0",
"@google-ai/generativelanguage": "0.2.1",
"@google/generative-ai": "0.8.0",
"@huggingface/inference": "2.6.4",
"@langchain/anthropic": "^0.1.16",
"@langchain/cohere": "^0.0.8",
"@langchain/community": "0.0.53",
"@langchain/core": "0.1.61",
"@langchain/google-genai": "^0.0.12",
"@langchain/groq": "^0.0.8",
"@langchain/mistralai": "0.0.19",
"@langchain/openai": "^0.0.28",
"@langchain/pinecone": "^0.0.4",
"@langchain/redis": "^0.0.2",
"@google-ai/generativelanguage": "2.5.0",
"@google/generative-ai": "0.11.4",
"@huggingface/inference": "2.7.0",
"@langchain/anthropic": "0.1.21",
"@langchain/cohere": "0.0.10",
"@langchain/community": "0.2.2",
"@langchain/core": "0.2.0",
"@langchain/google-genai": "0.0.16",
"@langchain/groq": "0.0.12",
"@langchain/mistralai": "0.0.22",
"@langchain/openai": "0.0.33",
"@langchain/pinecone": "0.0.6",
"@langchain/redis": "0.0.5",
"@langchain/textsplitters": "0.0.2",
"@n8n/typeorm": "0.3.20-9",
"@n8n/vm2": "3.9.20",
"@pinecone-database/pinecone": "2.2.0",
"@qdrant/js-client-rest": "1.7.0",
"@supabase/supabase-js": "2.38.5",
"@xata.io/client": "0.28.0",
"@pinecone-database/pinecone": "2.2.1",
"@qdrant/js-client-rest": "1.9.0",
"@supabase/supabase-js": "2.43.4",
"@xata.io/client": "0.28.4",
"basic-auth": "2.0.1",
"cohere-ai": "6.2.2",
"cohere-ai": "7.10.1",
"d3-dsv": "2.0.0",
"epub2": "3.0.2",
"form-data": "4.0.0",
"generate-schema": "^2.6.0",
"generate-schema": "2.6.0",
"html-to-text": "9.0.5",
"jest-mock-extended": "^3.0.4",
"json-schema-to-zod": "2.0.14",
"langchain": "0.1.36",
"json-schema-to-zod": "2.1.0",
"langchain": "0.2.2",
"lodash": "4.17.21",
"mammoth": "1.6.0",
"mammoth": "1.7.2",
"n8n-nodes-base": "workspace:*",
"n8n-workflow": "workspace:*",
"openai": "4.38.5",
"openai": "4.47.1",
"pdf-parse": "1.1.1",
"pg": "8.11.3",
"redis": "4.6.12",
"sqlite3": "5.1.7",
"temp": "0.9.4",
"tmp-promise": "3.0.3",
"zod": "3.22.4",
"zod-to-json-schema": "3.22.4"
"zod": "3.23.8",
"zod-to-json-schema": "3.23.0"
}
}
12 changes: 6 additions & 6 deletions packages/@n8n/nodes-langchain/utils/N8nBinaryLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { createWriteStream } from 'fs';
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { NodeOperationError, BINARY_ENCODING } from 'n8n-workflow';

import type { TextSplitter } from 'langchain/text_splitter';
import type { TextSplitter } from '@langchain/textsplitters';
import type { Document } from '@langchain/core/documents';
import { CSVLoader } from 'langchain/document_loaders/fs/csv';
import { DocxLoader } from 'langchain/document_loaders/fs/docx';
import { CSVLoader } from '@langchain/community/document_loaders/fs/csv';
import { DocxLoader } from '@langchain/community/document_loaders/fs/docx';
import { JSONLoader } from 'langchain/document_loaders/fs/json';
import { PDFLoader } from 'langchain/document_loaders/fs/pdf';
import { PDFLoader } from '@langchain/community/document_loaders/fs/pdf';
import { TextLoader } from 'langchain/document_loaders/fs/text';
import { EPubLoader } from 'langchain/document_loaders/fs/epub';
import { EPubLoader } from '@langchain/community/document_loaders/fs/epub';
import { file as tmpFile, type DirectoryResult } from 'tmp-promise';

import { getMetadataFiltersValues } from './helpers';
Expand Down Expand Up @@ -186,7 +186,7 @@ export class N8nBinaryLoader {
}

const loadedDoc = this.textSplitter
? await loader.loadAndSplit(this.textSplitter)
? await this.textSplitter.splitDocuments(await loader.load())
: await loader.load();

docs.push(...loadedDoc);
Expand Down
4 changes: 2 additions & 2 deletions packages/@n8n/nodes-langchain/utils/N8nJsonLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type IExecuteFunctions, type INodeExecutionData, NodeOperationError } from 'n8n-workflow';

import type { TextSplitter } from 'langchain/text_splitter';
import type { TextSplitter } from '@langchain/textsplitters';
import type { Document } from '@langchain/core/documents';
import { JSONLoader } from 'langchain/document_loaders/fs/json';
import { TextLoader } from 'langchain/document_loaders/fs/text';
Expand Down Expand Up @@ -75,7 +75,7 @@ export class N8nJsonLoader {
}

const docs = this.textSplitter
? await documentLoader.loadAndSplit(this.textSplitter)
? await this.textSplitter.splitDocuments(await documentLoader.load())
: await documentLoader.load();

if (metadata) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@n8n/nodes-langchain/utils/logWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { BaseCallbackConfig, Callbacks } from '@langchain/core/callbacks/ma
import { Embeddings } from '@langchain/core/embeddings';
import { VectorStore } from '@langchain/core/vectorstores';
import type { Document } from '@langchain/core/documents';
import { TextSplitter } from 'langchain/text_splitter';
import { TextSplitter } from '@langchain/textsplitters';
import { BaseChatMemory } from '@langchain/community/memory/chat_memory';
import { BaseRetriever } from '@langchain/core/retrievers';
import { BaseOutputParser, OutputParserException } from '@langchain/core/output_parsers';
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@
"ts-essentials": "^7.0.3"
},
"dependencies": {
"@langchain/community": "0.0.53",
"@langchain/core": "0.1.61",
"@langchain/openai": "0.0.28",
"@langchain/pinecone": "^0.0.3",
"@langchain/community": "0.2.2",
"@langchain/core": "0.2.0",
"@langchain/openai": "0.0.33",
"@langchain/pinecone": "0.0.6",
"@n8n/client-oauth2": "workspace:*",
"@n8n/localtunnel": "2.1.0",
"@n8n/n8n-nodes-langchain": "workspace:*",
Expand Down Expand Up @@ -141,7 +141,7 @@
"json-diff": "1.0.6",
"jsonschema": "1.4.1",
"jsonwebtoken": "9.0.2",
"langchain": "0.1.36",
"langchain": "0.2.2",
"ldapts": "4.2.6",
"lodash": "4.17.21",
"luxon": "3.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"dist/**/*"
],
"devDependencies": {
"@langchain/core": "^0.2.0",
"@types/deep-equal": "^1.0.1",
"@types/express": "^4.17.21",
"@types/jmespath": "^0.15.0",
Expand All @@ -65,7 +66,6 @@
"recast": "0.21.5",
"title-case": "3.0.3",
"transliteration": "2.3.5",
"xml2js": "0.6.2",
"@langchain/core": "0.1.61"
"xml2js": "0.6.2"
}
}
Loading

0 comments on commit a77e8dd

Please sign in to comment.