Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Update Langchain dependencies (no-changelog) #9252

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"sqlite3"
],
"overrides": {
"@langchain/core": "0.1.41",
"@types/node": "^18.16.16",
"axios": "1.6.7",
"chokidar": "3.5.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { zodToJsonSchema } from 'zod-to-json-schema';
import type { OpenAI as OpenAIClient } from 'openai';
import type { OpenAIClient } from '@langchain/openai';
import type { StructuredTool } from '@langchain/core/tools';

// Copied from langchain(`langchain/src/tools/convert_to_openai.ts`)
Expand Down Expand Up @@ -33,9 +33,7 @@ export function formatToOpenAITool(tool: StructuredTool): OpenAIClient.Chat.Chat
};
}

export function formatToOpenAIAssistantTool(
tool: StructuredTool,
): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction {
export function formatToOpenAIAssistantTool(tool: StructuredTool): OpenAIClient.Beta.AssistantTool {
return {
type: 'function',
function: {
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 { Calculator } from 'langchain/tools/calculator';
import { Calculator } from '@langchain/community/tools/calculator';
import { logWrapper } from '../../../utils/logWrapper';
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ export async function execute(this: IExecuteFunctions, i: number): Promise<INode
});
}

const useRetrieval = assistantTools.some((tool) => tool.type === 'retrieval');
const useRetrieval = assistantTools.some((tool) => tool.type === 'file_search');
if (useRetrieval) {
nativeToolsParsed.push({
type: 'retrieval',
type: 'file_search',
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export function formatToOpenAITool(tool: StructuredTool): OpenAIClient.Chat.Chat
};
}

export function formatToOpenAIAssistantTool(
tool: StructuredTool,
): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction {
export function formatToOpenAIAssistantTool(tool: StructuredTool): OpenAIClient.Beta.AssistantTool {
return {
type: 'function',
function: {
Expand Down
20 changes: 10 additions & 10 deletions packages/@n8n/nodes-langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,18 @@
"@google-ai/generativelanguage": "0.2.1",
"@google/generative-ai": "0.8.0",
"@huggingface/inference": "2.6.4",
"@langchain/anthropic": "^0.1.3",
"@langchain/cohere": "^0.0.5",
"@langchain/community": "0.0.44",
"@langchain/core": "0.1.41",
"@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/mistralai": "0.0.13",
"@langchain/openai": "^0.0.16",
"@langchain/pinecone": "^0.0.3",
"@langchain/mistralai": "0.0.19",
"@langchain/openai": "^0.0.28",
"@langchain/pinecone": "^0.0.4",
"@langchain/redis": "^0.0.2",
"@n8n/typeorm": "0.3.20-9",
"@n8n/vm2": "3.9.20",
"@pinecone-database/pinecone": "2.1.0",
"@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",
Expand All @@ -158,12 +158,12 @@
"html-to-text": "9.0.5",
"jest-mock-extended": "^3.0.4",
"json-schema-to-zod": "2.0.14",
"langchain": "0.1.25",
"langchain": "0.1.36",
"lodash": "4.17.21",
"mammoth": "1.6.0",
"n8n-nodes-base": "workspace:*",
"n8n-workflow": "workspace:*",
"openai": "4.26.1",
"openai": "4.38.5",
"pdf-parse": "1.1.1",
"pg": "8.11.3",
"redis": "4.6.12",
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@
"ts-essentials": "^7.0.3"
},
"dependencies": {
"@langchain/community": "0.0.44",
"@langchain/core": "0.1.41",
"@langchain/openai": "0.0.16",
"@langchain/community": "0.0.53",
"@langchain/core": "0.1.61",
"@langchain/openai": "0.0.28",
"@n8n/client-oauth2": "workspace:*",
"@n8n/localtunnel": "2.1.0",
"@n8n/n8n-nodes-langchain": "workspace:*",
Expand Down Expand Up @@ -138,7 +138,7 @@
"json-diff": "1.0.6",
"jsonschema": "1.4.1",
"jsonwebtoken": "9.0.2",
"langchain": "0.1.25",
"langchain": "0.1.36",
"ldapts": "4.2.6",
"lodash": "4.17.21",
"luxon": "3.3.0",
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/services/ai/providers/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ export class AIProviderOpenAI implements N8nAIProvider {
mapResponse(data: BaseMessageChunk): string {
if (Array.isArray(data.content)) {
return data.content
.map((message) =>
'text' in message ? message.text : 'image_url' in message ? message.image_url : '',
.map((message): string =>
'text' in message
? (message.text as string)
: 'image_url' in message
? (message.image_url as string)
: '',
)
.join('\n');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@
"title-case": "3.0.3",
"transliteration": "2.3.5",
"xml2js": "0.6.2",
"@langchain/core": "0.1.41"
"@langchain/core": "0.1.61"
}
}
Loading
Loading