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

📦 fix: npm warnings; chore: bump deprecated packages #4707

Merged
merged 20 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f0f6816
chore: bump langchain deps to address vulnerability warnings
maxesse Nov 7, 2024
fa3e6a4
chore: bump community package and install textsplitters package
danny-avila Nov 12, 2024
f2f874a
fix: update expected result in tokenSplit tests for accuracy
danny-avila Nov 12, 2024
a0e2584
chore: remove CodeSherpa tools
danny-avila Nov 12, 2024
c61343b
chore: remove E2B tools and loadToolSuite
danny-avila Nov 12, 2024
1781533
chore: remove CodeBrew tool and update related references
danny-avila Nov 12, 2024
11bec15
chore: remove HumanTool and ChatTool, update tool references
danny-avila Nov 12, 2024
1afcef8
chore: remove Zapier tool from manifest.json and update SerpAPI
danny-avila Nov 12, 2024
5c2d0e6
chore: remove basic tools
danny-avila Nov 12, 2024
de3d7c6
chore: update import path for RecursiveCharacterTextSplitter
danny-avila Nov 12, 2024
382c30c
chore: update import path for DynamicStructuredTool
danny-avila Nov 12, 2024
b70c0a5
chore: remove extractionChain.js and update tool filtering logic
danny-avila Nov 12, 2024
1e74634
chore: npm audit fix
danny-avila Nov 12, 2024
7335769
chore: bump google packages
danny-avila Nov 12, 2024
c3f9841
chore: update DALL-E tool to DALL-E-3 and adjust authentication logic
danny-avila Nov 12, 2024
f5647ce
ci: update message classes
danny-avila Nov 12, 2024
0597d2f
chore: elliptic npm audit fix
danny-avila Nov 12, 2024
aba574a
chore: update CallbackManager import and remove deprecated tool handl…
danny-avila Nov 12, 2024
ec93084
chore: imports order
danny-avila Nov 12, 2024
381ff02
chore: remove unused code
danny-avila Nov 12, 2024
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
@@ -1,11 +1,11 @@
const { google } = require('googleapis');
const { Agent, ProxyAgent } = require('undici');
const { ChatVertexAI } = require('@langchain/google-vertexai');
const { GoogleVertexAI } = require('@langchain/google-vertexai');
const { ChatGoogleVertexAI } = 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 { AIMessage, HumanMessage, SystemMessage } = require('@langchain/core/messages');
const { encoding_for_model: encodingForModel, get_encoding: getEncoding } = require('tiktoken');
const {
validateVisionModel,
Expand Down
9 changes: 3 additions & 6 deletions api/app/clients/PluginsClient.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const OpenAIClient = require('./OpenAIClient');
const { CallbackManager } = require('langchain/callbacks');
const { CacheKeys, Time } = require('librechat-data-provider');
const { CallbackManager } = require('@langchain/core/callbacks/manager');
const { BufferMemory, ChatMessageHistory } = require('langchain/memory');
const { initializeCustomAgent, initializeFunctionsAgent } = require('./agents');
const { addImages, buildErrorInput, buildPromptPrefix } = require('./output_parsers');
const { initializeCustomAgent, initializeFunctionsAgent } = require('./agents');
const { processFileURL } = require('~/server/services/Files/process');
const { EModelEndpoint } = require('librechat-data-provider');
const { formatLangChainMessages } = require('./prompts');
const checkBalance = require('~/models/checkBalance');
const { SelfReflectionTool } = require('./tools');
const { isEnabled } = require('~/server/utils');
const { extractBaseURL } = require('~/utils');
const { loadTools } = require('./tools/util');
Expand Down Expand Up @@ -122,9 +121,7 @@ class PluginsClient extends OpenAIClient {
},
});

if (this.tools.length > 0 && !this.functionsAgent) {
this.tools.push(new SelfReflectionTool({ message, isGpt3: false }));
} else if (this.tools.length === 0) {
if (this.tools.length === 0) {
return;
}

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
122 changes: 0 additions & 122 deletions api/app/clients/agents/Functions/FunctionsAgent.js

This file was deleted.

2 changes: 1 addition & 1 deletion api/app/clients/document/tokenSplit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { TokenTextSplitter } = require('langchain/text_splitter');
const { TokenTextSplitter } = require('@langchain/textsplitters');

/**
* Splits a given text by token chunks, based on the provided parameters for the TokenTextSplitter.
Expand Down
2 changes: 1 addition & 1 deletion api/app/clients/document/tokenSplit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('tokenSplit', () => {
returnSize: 5,
});

expect(result).toEqual(['. Null', ' Nullam', 'am id', ' id.', '.']);
expect(result).toEqual(['it.', '. Null', ' Nullam', 'am id', ' id.']);
});

it('returns correct text chunks with default parameters', async () => {
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 Expand Up @@ -206,7 +206,7 @@
]);
});

it.skip('should not produce two consecutive assistant messages and format content correctly', () => {

Check warning on line 209 in api/app/clients/prompts/formatAgentMessages.spec.js

View workflow job for this annotation

GitHub Actions / ESLint

api/app/clients/prompts/formatAgentMessages.spec.js#L209

Disabled test (jest/no-disabled-tests)
const payload = [
{ role: 'user', content: 'Hello' },
{
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
6 changes: 3 additions & 3 deletions 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 { HumanMessage, AIMessage } = require('@langchain/core/messages');
const PluginsClient = require('../PluginsClient');

jest.mock('~/lib/db/connectDb');
Expand Down Expand Up @@ -55,8 +55,8 @@ describe('PluginsClient', () => {

const chatMessages = orderedMessages.map((msg) =>
msg?.isCreatedByUser || msg?.role?.toLowerCase() === 'user'
? new HumanChatMessage(msg.text)
: new AIChatMessage(msg.text),
? new HumanMessage(msg.text)
: new AIMessage(msg.text),
);

TestAgent.currentMessages = orderedMessages;
Expand Down
98 changes: 0 additions & 98 deletions api/app/clients/tools/AzureAiSearch.js

This file was deleted.

Loading
Loading