mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 02:10:15 +01:00
🪦 refactor: Remove Legacy Code (#10533)
* 🗑️ chore: Remove unused Legacy Provider clients and related helpers * Deleted OpenAIClient and GoogleClient files along with their associated tests. * Removed references to these clients in the clients index file. * Cleaned up typedefs by removing the OpenAISpecClient export. * Updated chat controllers to use the OpenAI SDK directly instead of the removed client classes. * chore/remove-openapi-specs * 🗑️ chore: Remove unused mergeSort and misc utility functions * Deleted mergeSort.js and misc.js files as they are no longer needed. * Removed references to cleanUpPrimaryKeyValue in messages.js and adjusted related logic. * Updated mongoMeili.ts to eliminate local implementations of removed functions. * chore: remove legacy endpoints * chore: remove all plugins endpoint related code * chore: remove unused prompt handling code and clean up imports * Deleted handleInputs.js and instructions.js files as they are no longer needed. * Removed references to these files in the prompts index.js. * Updated docker-compose.yml to simplify reverse proxy configuration. * chore: remove unused LightningIcon import from Icons.tsx * chore: clean up translation.json by removing deprecated and unused keys * chore: update Jest configuration and remove unused mock file * Simplified the setupFiles array in jest.config.js by removing the fetchEventSource mock. * Deleted the fetchEventSource.js mock file as it is no longer needed. * fix: simplify endpoint type check in Landing and ConversationStarters components * Updated the endpoint type check to use strict equality for better clarity and performance. * Ensured consistency in the handling of the azureOpenAI endpoint across both components. * chore: remove unused dependencies from package.json and package-lock.json * chore: remove legacy EditController, associated routes and imports * chore: update banResponse logic to refine request handling for banned users * chore: remove unused validateEndpoint middleware and its references * chore: remove unused 'res' parameter from initializeClient in multiple endpoint files * chore: remove unused 'isSmallScreen' prop from BookmarkNav and NewChat components; clean up imports in ArchivedChatsTable and useSetIndexOptions hooks; enhance localization in PromptVersions * chore: remove unused import of Constants and TMessage from MobileNav; retain only necessary QueryKeys import * chore: remove unused TResPlugin type and related references; clean up imports in types and schemas
This commit is contained in:
parent
b6dcefc53a
commit
656e1abaea
161 changed files with 256 additions and 10513 deletions
|
|
@ -25,10 +25,6 @@ export enum EModelEndpoint {
|
|||
agents = 'agents',
|
||||
custom = 'custom',
|
||||
bedrock = 'bedrock',
|
||||
/** @deprecated */
|
||||
chatGPTBrowser = 'chatGPTBrowser',
|
||||
/** @deprecated */
|
||||
gptPlugins = 'gptPlugins',
|
||||
}
|
||||
|
||||
/** Mirrors `@librechat/agents` providers */
|
||||
|
|
@ -529,16 +525,6 @@ export type TInput = {
|
|||
inputStr: string;
|
||||
};
|
||||
|
||||
export type TResPlugin = {
|
||||
plugin: string;
|
||||
input: string;
|
||||
thought: string;
|
||||
loading?: boolean;
|
||||
outputs?: string;
|
||||
latest?: string;
|
||||
inputs?: TInput[];
|
||||
};
|
||||
|
||||
export const tExampleSchema = z.object({
|
||||
input: z.object({
|
||||
content: z.string(),
|
||||
|
|
@ -550,39 +536,6 @@ export const tExampleSchema = z.object({
|
|||
|
||||
export type TExample = z.infer<typeof tExampleSchema>;
|
||||
|
||||
export enum EAgent {
|
||||
functions = 'functions',
|
||||
classic = 'classic',
|
||||
}
|
||||
|
||||
export const agentOptionSettings = {
|
||||
model: {
|
||||
default: 'gpt-4o-mini',
|
||||
},
|
||||
temperature: {
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.01,
|
||||
default: 0,
|
||||
},
|
||||
agent: {
|
||||
default: EAgent.functions,
|
||||
options: [EAgent.functions, EAgent.classic],
|
||||
},
|
||||
skipCompletion: {
|
||||
default: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const eAgentOptionsSchema = z.nativeEnum(EAgent);
|
||||
|
||||
export const tAgentOptionsSchema = z.object({
|
||||
agent: z.string().default(EAgent.functions),
|
||||
skipCompletion: z.boolean().default(agentOptionSettings.skipCompletion.default),
|
||||
model: z.string(),
|
||||
temperature: z.number().default(agentOptionSettings.temperature.default),
|
||||
});
|
||||
|
||||
export const tMessageSchema = z.object({
|
||||
messageId: z.string(),
|
||||
endpoint: z.string().optional(),
|
||||
|
|
@ -659,8 +612,6 @@ export type TAttachment =
|
|||
|
||||
export type TMessage = z.input<typeof tMessageSchema> & {
|
||||
children?: TMessage[];
|
||||
plugin?: TResPlugin | null;
|
||||
plugins?: TResPlugin[];
|
||||
content?: TMessageContentParts[];
|
||||
files?: Partial<TFile>[];
|
||||
depth?: number;
|
||||
|
|
@ -775,8 +726,6 @@ export const tConversationSchema = z.object({
|
|||
fileTokenLimit: coerceNumber.optional(),
|
||||
/** @deprecated */
|
||||
resendImages: z.boolean().optional(),
|
||||
/** @deprecated */
|
||||
agentOptions: tAgentOptionsSchema.nullable().optional(),
|
||||
/** @deprecated Prefer `modelLabel` over `chatGptLabel` */
|
||||
chatGptLabel: z.string().nullable().optional(),
|
||||
});
|
||||
|
|
@ -982,75 +931,6 @@ export const googleGenConfigSchema = z
|
|||
.strip()
|
||||
.optional();
|
||||
|
||||
const gptPluginsBaseSchema = tConversationSchema.pick({
|
||||
model: true,
|
||||
modelLabel: true,
|
||||
chatGptLabel: true,
|
||||
promptPrefix: true,
|
||||
temperature: true,
|
||||
artifacts: true,
|
||||
top_p: true,
|
||||
presence_penalty: true,
|
||||
frequency_penalty: true,
|
||||
tools: true,
|
||||
agentOptions: true,
|
||||
iconURL: true,
|
||||
greeting: true,
|
||||
spec: true,
|
||||
maxContextTokens: true,
|
||||
});
|
||||
|
||||
export const gptPluginsSchema = gptPluginsBaseSchema
|
||||
.transform((obj) => {
|
||||
const result = {
|
||||
...obj,
|
||||
model: obj.model ?? 'gpt-3.5-turbo',
|
||||
chatGptLabel: obj.chatGptLabel ?? obj.modelLabel ?? null,
|
||||
promptPrefix: obj.promptPrefix ?? null,
|
||||
temperature: obj.temperature ?? 0.8,
|
||||
top_p: obj.top_p ?? 1,
|
||||
presence_penalty: obj.presence_penalty ?? 0,
|
||||
frequency_penalty: obj.frequency_penalty ?? 0,
|
||||
tools: obj.tools ?? [],
|
||||
agentOptions: obj.agentOptions ?? {
|
||||
agent: EAgent.functions,
|
||||
skipCompletion: true,
|
||||
model: 'gpt-3.5-turbo',
|
||||
temperature: 0,
|
||||
},
|
||||
iconURL: obj.iconURL ?? undefined,
|
||||
greeting: obj.greeting ?? undefined,
|
||||
spec: obj.spec ?? undefined,
|
||||
maxContextTokens: obj.maxContextTokens ?? undefined,
|
||||
};
|
||||
|
||||
if (obj.modelLabel != null && obj.modelLabel !== '') {
|
||||
result.modelLabel = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
})
|
||||
.catch(() => ({
|
||||
model: 'gpt-3.5-turbo',
|
||||
chatGptLabel: null,
|
||||
promptPrefix: null,
|
||||
temperature: 0.8,
|
||||
top_p: 1,
|
||||
presence_penalty: 0,
|
||||
frequency_penalty: 0,
|
||||
tools: [],
|
||||
agentOptions: {
|
||||
agent: EAgent.functions,
|
||||
skipCompletion: true,
|
||||
model: 'gpt-3.5-turbo',
|
||||
temperature: 0,
|
||||
},
|
||||
iconURL: undefined,
|
||||
greeting: undefined,
|
||||
spec: undefined,
|
||||
maxContextTokens: undefined,
|
||||
}));
|
||||
|
||||
export function removeNullishValues<T extends Record<string, unknown>>(
|
||||
obj: T,
|
||||
removeEmptyStrings?: boolean,
|
||||
|
|
@ -1251,48 +1131,6 @@ export const anthropicSchema = anthropicBaseSchema
|
|||
.transform((obj) => removeNullishValues(obj))
|
||||
.catch(() => ({}));
|
||||
|
||||
export const compactPluginsSchema = gptPluginsBaseSchema
|
||||
.transform((obj) => {
|
||||
const newObj: Partial<TConversation> = { ...obj };
|
||||
if (newObj.modelLabel === null) {
|
||||
delete newObj.modelLabel;
|
||||
}
|
||||
if (newObj.chatGptLabel === null) {
|
||||
delete newObj.chatGptLabel;
|
||||
}
|
||||
if (newObj.promptPrefix === null) {
|
||||
delete newObj.promptPrefix;
|
||||
}
|
||||
if (newObj.temperature === 0.8) {
|
||||
delete newObj.temperature;
|
||||
}
|
||||
if (newObj.top_p === 1) {
|
||||
delete newObj.top_p;
|
||||
}
|
||||
if (newObj.presence_penalty === 0) {
|
||||
delete newObj.presence_penalty;
|
||||
}
|
||||
if (newObj.frequency_penalty === 0) {
|
||||
delete newObj.frequency_penalty;
|
||||
}
|
||||
if (newObj.tools?.length === 0) {
|
||||
delete newObj.tools;
|
||||
}
|
||||
|
||||
if (
|
||||
newObj.agentOptions &&
|
||||
newObj.agentOptions.agent === EAgent.functions &&
|
||||
newObj.agentOptions.skipCompletion === true &&
|
||||
newObj.agentOptions.model === 'gpt-3.5-turbo' &&
|
||||
newObj.agentOptions.temperature === 0
|
||||
) {
|
||||
delete newObj.agentOptions;
|
||||
}
|
||||
|
||||
return removeNullishValues(newObj);
|
||||
})
|
||||
.catch(() => ({}));
|
||||
|
||||
export const tBannerSchema = z.object({
|
||||
bannerId: z.string(),
|
||||
message: z.string(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue