diff --git a/api/server/controllers/EndpointController.js b/api/server/controllers/EndpointController.js index 1e716870c32..82bfa5f2acf 100644 --- a/api/server/controllers/EndpointController.js +++ b/api/server/controllers/EndpointController.js @@ -27,6 +27,15 @@ async function endpointController(req, res) { capabilities, }; } + if (mergedConfig[EModelEndpoint.agents] && req.app.locals?.[EModelEndpoint.agents]) { + const { disableBuilder, capabilities, ..._rest } = req.app.locals[EModelEndpoint.agents]; + + mergedConfig[EModelEndpoint.agents] = { + ...mergedConfig[EModelEndpoint.agents], + disableBuilder, + capabilities, + }; + } if ( mergedConfig[EModelEndpoint.azureAssistants] && diff --git a/api/server/services/AppService.js b/api/server/services/AppService.js index 19a9fc91a99..0ec27962a52 100644 --- a/api/server/services/AppService.js +++ b/api/server/services/AppService.js @@ -7,6 +7,7 @@ const handleRateLimits = require('./Config/handleRateLimits'); const { loadDefaultInterface } = require('./start/interface'); const { azureConfigSetup } = require('./start/azureOpenAI'); const { loadAndFormatTools } = require('./ToolService'); +const { agentsConfigSetup } = require('./start/agents'); const { initializeRoles } = require('~/models/Role'); const paths = require('~/config/paths'); @@ -94,6 +95,10 @@ const AppService = async (app) => { ); } + if (endpoints?.[EModelEndpoint.agents]) { + endpointLocals[EModelEndpoint.agents] = agentsConfigSetup(config); + } + const endpointKeys = [ EModelEndpoint.openAI, EModelEndpoint.google, diff --git a/api/server/services/start/agents.js b/api/server/services/start/agents.js new file mode 100644 index 00000000000..10653f3fb67 --- /dev/null +++ b/api/server/services/start/agents.js @@ -0,0 +1,14 @@ +const { EModelEndpoint, agentsEndpointSChema } = require('librechat-data-provider'); + +/** + * Sets up the Agents configuration from the config (`librechat.yaml`) file. + * @param {TCustomConfig} config - The loaded custom configuration. + * @returns {Partial} The Agents endpoint configuration. + */ +function agentsConfigSetup(config) { + const agentsConfig = config.endpoints[EModelEndpoint.agents]; + const parsedConfig = agentsEndpointSChema.parse(agentsConfig); + return parsedConfig; +} + +module.exports = { agentsConfigSetup }; diff --git a/api/typedefs.js b/api/typedefs.js index a80a25609da..2c799585ae2 100644 --- a/api/typedefs.js +++ b/api/typedefs.js @@ -819,11 +819,17 @@ */ /** - * @exports TAssistantEndpoint + * @exports TAgentsEndpoint * @typedef {import('librechat-data-provider').TAssistantEndpoint} TAssistantEndpoint * @memberof typedefs */ +/** + * @exports TAgentsEndpoint + * @typedef {import('librechat-data-provider').TAgentsEndpoint} TAgentsEndpoint + * @memberof typedefs + */ + /** * @exports Agent * @typedef {import('librechat-data-provider').Agent} Agent diff --git a/client/src/common/types.ts b/client/src/common/types.ts index f274239fbf6..b3875277838 100644 --- a/client/src/common/types.ts +++ b/client/src/common/types.ts @@ -173,6 +173,7 @@ export type AgentPanelProps = { setAction: React.Dispatch>; endpointsConfig?: t.TEndpointsConfig; setCurrentAgentId: React.Dispatch>; + agentsConfig?: t.TAgentsEndpoint | null; }; export type AgentModelPanelProps = { diff --git a/client/src/components/SidePanel/Agents/AgentConfig.tsx b/client/src/components/SidePanel/Agents/AgentConfig.tsx index 798e75c1bde..6ff5347faeb 100644 --- a/client/src/components/SidePanel/Agents/AgentConfig.tsx +++ b/client/src/components/SidePanel/Agents/AgentConfig.tsx @@ -9,7 +9,7 @@ import { PermissionTypes, AgentCapabilities, } from 'librechat-data-provider'; -import type { TConfig, TPlugin } from 'librechat-data-provider'; +import type { TPlugin } from 'librechat-data-provider'; import type { AgentForm, AgentPanelProps } from '~/common'; import { cn, defaultTextProps, removeFocusOutlines, getEndpointField, getIconKey } from '~/utils'; import { useCreateAgentMutation, useUpdateAgentMutation } from '~/data-provider'; @@ -43,7 +43,7 @@ export default function AgentConfig({ endpointsConfig, setActivePanel, setCurrentAgentId, -}: AgentPanelProps & { agentsConfig?: TConfig | null }) { +}: AgentPanelProps) { const { user } = useAuthContext(); const fileMap = useFileMapContext(); const queryClient = useQueryClient(); @@ -69,19 +69,19 @@ export default function AgentConfig({ }); const toolsEnabled = useMemo( - () => agentsConfig?.capabilities?.includes(AgentCapabilities.tools), + () => agentsConfig?.capabilities.includes(AgentCapabilities.tools), [agentsConfig], ); const actionsEnabled = useMemo( - () => agentsConfig?.capabilities?.includes(AgentCapabilities.actions), + () => agentsConfig?.capabilities.includes(AgentCapabilities.actions), [agentsConfig], ); const fileSearchEnabled = useMemo( - () => agentsConfig?.capabilities?.includes(AgentCapabilities.file_search) ?? false, + () => agentsConfig?.capabilities.includes(AgentCapabilities.file_search) ?? false, [agentsConfig], ); const codeEnabled = useMemo( - () => agentsConfig?.capabilities?.includes(AgentCapabilities.execute_code) ?? false, + () => agentsConfig?.capabilities.includes(AgentCapabilities.execute_code) ?? false, [agentsConfig], ); diff --git a/client/src/components/SidePanel/Agents/AgentPanel.tsx b/client/src/components/SidePanel/Agents/AgentPanel.tsx index dec5e333d4a..a05fa39f175 100644 --- a/client/src/components/SidePanel/Agents/AgentPanel.tsx +++ b/client/src/components/SidePanel/Agents/AgentPanel.tsx @@ -8,7 +8,6 @@ import { isAssistantsEndpoint, defaultAgentFormValues, } from 'librechat-data-provider'; -import type { TConfig } from 'librechat-data-provider'; import type { AgentForm, AgentPanelProps, StringOption } from '~/common'; import { useCreateAgentMutation, @@ -33,7 +32,7 @@ export default function AgentPanel({ setCurrentAgentId, agentsConfig, endpointsConfig, -}: AgentPanelProps & { agentsConfig?: TConfig | null }) { +}: AgentPanelProps) { const localize = useLocalize(); const { user } = useAuthContext(); const { showToast } = useToastContext(); diff --git a/client/src/components/SidePanel/Builder/Code.tsx b/client/src/components/SidePanel/Builder/Code.tsx index c0b421cb9f2..54341194fe2 100644 --- a/client/src/components/SidePanel/Builder/Code.tsx +++ b/client/src/components/SidePanel/Builder/Code.tsx @@ -30,26 +30,29 @@ export default function Code({ version }: { version: number | string }) { checked={field.value} onCheckedChange={field.onChange} className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer" - value={field?.value?.toString()} + value={field.value.toString()} /> )} /> -
+
+
diff --git a/client/src/hooks/Nav/useSideNavLinks.ts b/client/src/hooks/Nav/useSideNavLinks.ts index 9cddf8720c6..c6430942456 100644 --- a/client/src/hooks/Nav/useSideNavLinks.ts +++ b/client/src/hooks/Nav/useSideNavLinks.ts @@ -76,7 +76,7 @@ export default function useSideNavLinks({ hasAccessToCreateAgents && isAgentsEndpoint(endpoint) && agents && - // agents.disableBuilder !== true && + agents.disableBuilder !== true && keyProvided && interfaceConfig.parameters === true ) { diff --git a/client/src/localization/languages/Eng.ts b/client/src/localization/languages/Eng.ts index 01e78d7bba9..d29d8b6a75b 100644 --- a/client/src/localization/languages/Eng.ts +++ b/client/src/localization/languages/Eng.ts @@ -119,7 +119,7 @@ export default { com_agents_enable_file_search: 'Enable File Search', com_agents_file_search_info: 'When enabled, the agent will be informed of the exact filenames listed below, allowing it to retrieve relevant context from these files.', - com_agents_code_interpreter_title: 'Code Interpreter', + com_agents_code_interpreter_title: 'Code Interpreter API', com_agents_by_librechat: 'by LibreChat', com_agents_code_interpreter: 'When enabled, allows your agent to leverage the LibreChat Code Interpreter API to run generated code, including file processing, securely. Requires a valid API key.', diff --git a/package-lock.json b/package-lock.json index 7d2879ccb13..7beb44c32e2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36153,7 +36153,7 @@ }, "packages/data-provider": { "name": "librechat-data-provider", - "version": "0.7.60", + "version": "0.7.61", "license": "ISC", "dependencies": { "@types/js-yaml": "^4.0.9", diff --git a/packages/data-provider/package.json b/packages/data-provider/package.json index 31720d215f4..65c45ebfcc6 100644 --- a/packages/data-provider/package.json +++ b/packages/data-provider/package.json @@ -1,6 +1,6 @@ { "name": "librechat-data-provider", - "version": "0.7.60", + "version": "0.7.61", "description": "data services for librechat apps", "main": "dist/index.js", "module": "dist/index.es.js", diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index dad4bed5b17..b3c2cb136f2 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -208,37 +208,17 @@ export type TAssistantEndpoint = z.infer; export const agentsEndpointSChema = baseEndpointSchema.merge( z.object({ - /* assistants specific */ + /* agents specific */ disableBuilder: z.boolean().optional(), - pollIntervalMs: z.number().optional(), - timeoutMs: z.number().optional(), - version: z.union([z.string(), z.number()]).default(2), - supportedIds: z.array(z.string()).min(1).optional(), - excludedIds: z.array(z.string()).min(1).optional(), - privateAssistants: z.boolean().optional(), - retrievalModels: z.array(z.string()).min(1).optional().default(defaultRetrievalModels), capabilities: z - .array(z.nativeEnum(Capabilities)) + .array(z.nativeEnum(AgentCapabilities)) .optional() .default([ - Capabilities.code_interpreter, - Capabilities.image_vision, - Capabilities.retrieval, - Capabilities.actions, - Capabilities.tools, + AgentCapabilities.execute_code, + AgentCapabilities.file_search, + AgentCapabilities.actions, + AgentCapabilities.tools, ]), - /* general */ - apiKey: z.string().optional(), - models: z - .object({ - default: z.array(z.string()).min(1), - fetch: z.boolean().optional(), - userIdQuery: z.boolean().optional(), - }) - .optional(), - titleConvo: z.boolean().optional(), - titleMethod: z.union([z.literal('completion'), z.literal('functions')]).optional(), - headers: z.record(z.any()).optional(), }), ); @@ -1097,7 +1077,7 @@ export enum Constants { /** Key for the app's version. */ VERSION = 'v0.7.5', /** Key for the Custom Config's version (librechat.yaml). */ - CONFIG_VERSION = '1.1.8', + CONFIG_VERSION = '1.1.9', /** Standard value for the first message's `parentMessageId` value, to indicate no parent exists. */ NO_PARENT = '00000000-0000-0000-0000-000000000000', /** Standard value for the initial conversationId before a request is sent */