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

chore: bump langchain deps to address vulnerability warnings #4662

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions api/app/clients/GoogleClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const { Agent, ProxyAgent } = require('undici');
const { ChatVertexAI } = require('@langchain/google-vertexai');
const { ChatGoogleGenerativeAI } = require('@langchain/google-genai');
const { GoogleGenerativeAI: GenAI } = require('@google/generative-ai');
const { GoogleVertexAI } = require('@langchain/community/llms/googlevertexai');
const { ChatGoogleVertexAI } = require('langchain/chat_models/googlevertexai');
const { AIMessage, HumanMessage, SystemMessage } = require('langchain/schema');
const { GoogleVertexAI } = require('@langchain/google-vertexai');
const { ChatGoogleVertexAI } = require('@langchain/google-vertexai');
const { AIMessage, HumanMessage, SystemMessage } = require('@langchain/core/messages');
const { encoding_for_model: encodingForModel, get_encoding: getEncoding } = require('tiktoken');
const {
validateVisionModel,
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/agents/CustomAgent/CustomAgent.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { ZeroShotAgent } = require('langchain/agents');
const { PromptTemplate, renderTemplate } = require('langchain/prompts');
const { PromptTemplate, renderTemplate } = require('@langchain/core/prompts');
const { gpt3, gpt4 } = require('./instructions');

class CustomAgent extends ZeroShotAgent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
ChatPromptTemplate,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate,
} = require('langchain/prompts');
} = require('@langchain/core/prompts');

const initializeCustomAgent = async ({
tools,
Expand Down
4 changes: 2 additions & 2 deletions api/app/clients/agents/Functions/FunctionsAgent.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { Agent } = require('langchain/agents');
const { LLMChain } = require('langchain/chains');
const { FunctionChatMessage, AIChatMessage } = require('langchain/schema');
const { FunctionChatMessage, AIChatMessage } = require('@langchain/core/messages');
const {
ChatPromptTemplate,
MessagesPlaceholder,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate,
} = require('langchain/prompts');
} = require('@langchain/core/prompts');
const { logger } = require('~/config');

const PREFIX = 'You are a helpful AI assistant.';
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/llm/createLLM.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ChatOpenAI } = require('langchain/chat_models/openai');
const { ChatOpenAI } = require('@langchain/openai');
const { sanitizeModelName, constructAzureURL } = require('~/utils');
const { isEnabled } = require('~/server/utils');

Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/memory/summaryBuffer.demo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('dotenv').config();
const { ChatOpenAI } = require('langchain/chat_models/openai');
const { ChatOpenAI } = require('@langchain/openai');
const { getBufferString, ConversationSummaryBufferMemory } = require('langchain/memory');

const chatPromptMemory = new ConversationSummaryBufferMemory({
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/prompts/formatAgentMessages.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { ToolMessage } = require('@langchain/core/messages');
const { ContentTypes } = require('librechat-data-provider');
const { HumanMessage, AIMessage, SystemMessage } = require('langchain/schema');
const { HumanMessage, AIMessage, SystemMessage } = require('@langchain/core/messages');
const { formatAgentMessages } = require('./formatMessages');

describe('formatAgentMessages', () => {
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/prompts/formatMessages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { ToolMessage } = require('@langchain/core/messages');
const { EModelEndpoint, ContentTypes } = require('librechat-data-provider');
const { HumanMessage, AIMessage, SystemMessage } = require('langchain/schema');
const { HumanMessage, AIMessage, SystemMessage } = require('@langchain/core/messages');

/**
* Formats a message to OpenAI Vision API payload format.
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/prompts/formatMessages.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { Constants } = require('librechat-data-provider');
const { HumanMessage, AIMessage, SystemMessage } = require('langchain/schema');
const { HumanMessage, AIMessage, SystemMessage } = require('@langchain/core/messages');
const { formatMessage, formatLangChainMessages, formatFromLangChain } = require('./formatMessages');

describe('formatMessage', () => {
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/prompts/summaryPrompts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { PromptTemplate } = require('langchain/prompts');
const { PromptTemplate } = require('@langchain/core/prompts');
/*
* Without `{summary}` and `{new_lines}`, token count is 98
* We are counting this towards the max context tokens for summaries, +3 for the assistant label (101)
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/prompts/titlePrompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {
ChatPromptTemplate,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate,
} = require('langchain/prompts');
} = require('@langchain/core/prompts');

const langPrompt = new ChatPromptTemplate({
promptMessages: [
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/specs/BaseClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jest.mock('~/models', () => ({
updateFileUsage: jest.fn(),
}));

jest.mock('langchain/chat_models/openai', () => {
jest.mock('@langchain/openai', () => {
return {
ChatOpenAI: jest.fn().mockImplementation(() => {
return {};
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/specs/OpenAIClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jest.mock('~/models', () => ({
updateFileUsage: jest.fn(),
}));

jest.mock('langchain/chat_models/openai', () => {
jest.mock('@langchain/openai', () => {
return {
ChatOpenAI: jest.fn().mockImplementation(() => {
return {};
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/specs/PluginsClient.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const crypto = require('crypto');
const { Constants } = require('librechat-data-provider');
const { HumanChatMessage, AIChatMessage } = require('langchain/schema');
const { HumanChatMessage, AIChatMessage } = require('@langchain/core/messages');
const PluginsClient = require('../PluginsClient');

jest.mock('~/lib/db/connectDb');
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/tools/dynamic/OpenAPIPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path');
const yaml = require('js-yaml');
const { createOpenAPIChain } = require('langchain/chains');
const { DynamicStructuredTool } = require('langchain/tools');
const { ChatPromptTemplate, HumanMessagePromptTemplate } = require('langchain/prompts');
const { ChatPromptTemplate, HumanMessagePromptTemplate } = require('@langchain/core/prompts');
const { logger } = require('~/config');

function addLinePrefix(text, prefix = '// ') {
Expand Down
4 changes: 2 additions & 2 deletions api/app/clients/tools/structured/E2BTools.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { z } = require('zod');
const axios = require('axios');
const { StructuredTool } = require('langchain/tools');
const { PromptTemplate } = require('langchain/prompts');
// const { ChatOpenAI } = require('langchain/chat_models/openai');
const { PromptTemplate } = require('@langchain/core/prompts');
// const { ChatOpenAI } = require('@langchain/openai');
const { createExtractionChainFromZod } = require('./extractionChain');
const { logger } = require('~/config');

Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/tools/structured/extractionChain.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { zodToJsonSchema } = require('zod-to-json-schema');
const { PromptTemplate } = require('langchain/prompts');
const { PromptTemplate } = require('@langchain/core/prompts');
const { JsonKeyOutputFunctionsParser } = require('langchain/output_parsers');
const { LLMChain } = require('langchain/chains');
function getExtractionFunctions(schema) {
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/tools/util/handleTools.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Tools } = require('librechat-data-provider');
const { ZapierToolKit } = require('langchain/agents');
const { Calculator } = require('langchain/tools/calculator');
const { Calculator } = require('@langchain/community/tools/calculator');
const { SerpAPI, ZapierNLAWrapper } = require('langchain/tools');
const { createCodeExecutionTool, EnvVar } = require('@librechat/agents');
const { getUserPluginAuthValue } = require('~/server/services/PluginService');
Expand Down
4 changes: 2 additions & 2 deletions api/app/clients/tools/util/handleTools.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jest.mock('~/models/User', () => {

jest.mock('~/server/services/PluginService', () => mockPluginService);

const { Calculator } = require('langchain/tools/calculator');
const { BaseChatModel } = require('langchain/chat_models/openai');
const { Calculator } = require('@langchain/community/tools/calculator');
const { BaseChatModel } = require('@langchain/openai');

const User = require('~/models/User');
const PluginService = require('~/server/services/PluginService');
Expand Down
10 changes: 5 additions & 5 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
"@google/generative-ai": "^0.5.0",
"@keyv/mongo": "^2.1.8",
"@keyv/redis": "^2.8.1",
"@langchain/community": "^0.0.46",
"@langchain/core": "^0.2.18",
"@langchain/google-genai": "^0.0.11",
"@langchain/google-vertexai": "^0.0.17",
"@langchain/community": "^0.3.12",
"@langchain/core": "^0.3.17",
"@langchain/google-genai": "^0.1.3",
"@langchain/google-vertexai": "^0.1.0",
"@librechat/agents": "^1.7.7",
"axios": "^1.7.7",
"bcryptjs": "^2.4.3",
Expand Down Expand Up @@ -70,7 +70,7 @@
"keyv": "^4.5.4",
"keyv-file": "^0.2.0",
"klona": "^2.0.6",
"langchain": "^0.0.214",
"langchain": "^0.2.19",
"librechat-data-provider": "*",
"lodash": "^4.17.21",
"meilisearch": "^0.38.0",
Expand Down
2 changes: 1 addition & 1 deletion api/server/services/ToolService.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs');
const path = require('path');
const { zodToJsonSchema } = require('zod-to-json-schema');
const { Calculator } = require('langchain/tools/calculator');
const { Calculator } = require('@langchain/community/tools/calculator');
const { tool: toolFn, Tool } = require('@langchain/core/tools');
const {
Tools,
Expand Down
Loading
Loading