| | import { AuthType, EToolResources } from 'librechat-data-provider'; |
| | import type { TPlugin } from 'librechat-data-provider'; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | export const filterUniquePlugins = (plugins?: TPlugin[]): TPlugin[] => { |
| | const seen = new Set(); |
| | return ( |
| | plugins?.filter((plugin) => { |
| | const duplicate = seen.has(plugin.pluginKey); |
| | seen.add(plugin.pluginKey); |
| | return !duplicate; |
| | }) || [] |
| | ); |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | export const checkPluginAuth = (plugin?: TPlugin): boolean => { |
| | if (!plugin?.authConfig || plugin.authConfig.length === 0) { |
| | return false; |
| | } |
| |
|
| | return plugin.authConfig.every((authFieldObj) => { |
| | const authFieldOptions = authFieldObj.authField.split('||'); |
| | let isFieldAuthenticated = false; |
| |
|
| | for (const fieldOption of authFieldOptions) { |
| | const envValue = process.env[fieldOption]; |
| | if (envValue && envValue.trim() !== '' && envValue !== AuthType.USER_PROVIDED) { |
| | isFieldAuthenticated = true; |
| | break; |
| | } |
| | } |
| |
|
| | return isFieldAuthenticated; |
| | }); |
| | }; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | export function getToolkitKey({ |
| | toolkits, |
| | toolName, |
| | }: { |
| | toolkits: TPlugin[]; |
| | toolName?: string; |
| | }): string | undefined { |
| | let toolkitKey: string | undefined; |
| | if (!toolName) { |
| | return toolkitKey; |
| | } |
| | for (const toolkit of toolkits) { |
| | if (toolName.startsWith(EToolResources.image_edit)) { |
| | const splitMatches = toolkit.pluginKey.split('_'); |
| | const suffix = splitMatches[splitMatches.length - 1]; |
| | if (toolName.endsWith(suffix)) { |
| | toolkitKey = toolkit.pluginKey; |
| | break; |
| | } |
| | } |
| | if (toolName.startsWith(toolkit.pluginKey)) { |
| | toolkitKey = toolkit.pluginKey; |
| | break; |
| | } |
| | } |
| | return toolkitKey; |
| | } |
| |
|