Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🤖 fix: Minor Assistants Endpoint Fixes (#2472)

Danny Avilae6310c806a19
diff --git a/api/server/services/AppService.js b/api/server/services/AppService.js
index c9c42a2a1a..87c4a2394f 100644
--- a/api/server/services/AppService.js
+++ b/api/server/services/AppService.js
@@ -5,8 +5,8 @@ const {
defaultSocialLogins,
} = require('librechat-data-provider');
const { checkVariables, checkHealth, checkConfig, checkAzureVariables } = require('./start/checks');
+const { azureAssistantsDefaults, assistantsConfigSetup } = require('./start/assistants');
const { initializeFirebase } = require('./Files/Firebase/initialize');
-const { assistantsConfigSetup } = require('./start/assistants');
const loadCustomConfig = require('./Config/loadCustomConfig');
const handleRateLimits = require('./Config/handleRateLimits');
const { azureConfigSetup } = require('./start/azureOpenAI');
@@ -70,8 +70,15 @@ const AppService = async (app) => {
checkAzureVariables();
}
+ if (config?.endpoints?.[EModelEndpoint.azureOpenAI]?.assistants) {
+ endpointLocals[EModelEndpoint.assistants] = azureAssistantsDefaults();
+ }
+
if (config?.endpoints?.[EModelEndpoint.assistants]) {
- endpointLocals[EModelEndpoint.assistants] = assistantsConfigSetup(config);
+ endpointLocals[EModelEndpoint.assistants] = assistantsConfigSetup(
+ config,
+ endpointLocals[EModelEndpoint.assistants],
+ );
}
app.locals = {
diff --git a/api/server/services/AppService.spec.js b/api/server/services/AppService.spec.js
index dd8e0c0068..bf71ece6ed 100644
--- a/api/server/services/AppService.spec.js
+++ b/api/server/services/AppService.spec.js
@@ -154,9 +154,7 @@ describe('AppService', () => {
});
it('should default to `PNG` `imageOutputType` with no provided config', async () => {
- require('./Config/loadCustomConfig').mockImplementationOnce(() =>
- Promise.resolve(undefined),
- );
+ require('./Config/loadCustomConfig').mockImplementationOnce(() => Promise.resolve(undefined));
await AppService(app);
expect(app.locals.imageOutputType).toEqual(EImageOutputType.PNG);
@@ -230,6 +228,27 @@ describe('AppService', () => {
);
});
+ it('should correctly configure minimum Azure OpenAI Assistant values', async () => {
+ const assistantGroups = [azureGroups[0], { ...azureGroups[1], assistants: true }];
+ require('./Config/loadCustomConfig').mockImplementationOnce(() =>
+ Promise.resolve({
+ endpoints: {
+ [EModelEndpoint.azureOpenAI]: {
+ groups: assistantGroups,
+ assistants: true,
+ },
+ },
+ }),
+ );
+
+ process.env.WESTUS_API_KEY = 'westus-key';
+ process.env.EASTUS_API_KEY = 'eastus-key';
+
+ await AppService(app);
+ expect(app.locals).toHaveProperty(EModelEndpoint.assistants);
+ expect(app.locals[EModelEndpoint.assistants].capabilities.length).toEqual(3);
+ });
+
it('should correctly configure Azure OpenAI endpoint based on custom config', async () => {
require('./Config/loadCustomConfig').mockImplementationOnce(() =>
Promise.resolve({
diff --git a/api/server/services/start/assistants.js b/api/server/services/start/assistants.js
index c092318ce8..dfef99e591 100644
--- a/api/server/services/start/assistants.js
+++ b/api/server/services/start/assistants.js
@@ -5,12 +5,24 @@ const {
} = require('librechat-data-provider');
const { logger } = require('~/config');
+/**
+ * Sets up the minimum, default Assistants configuration if Azure OpenAI Assistants option is enabled.
+ * @returns {Partial<TAssistantEndpoint>} The Assistants endpoint configuration.
+ */
+function azureAssistantsDefaults() {
+ return {
+ capabilities: [Capabilities.tools, Capabilities.actions, Capabilities.code_interpreter],
+ };
+}
+
/**
* Sets up the Assistants configuration from the config (`librechat.yaml`) file.
* @param {TCustomConfig} config - The loaded custom configuration.
+ * @param {Partial<TAssistantEndpoint>} [prevConfig]
+ * - The previously loaded assistants configuration from Azure OpenAI Assistants option.
* @returns {Partial<TAssistantEndpoint>} The Assistants endpoint configuration.
*/
-function assistantsConfigSetup(config) {
+function assistantsConfigSetup(config, prevConfig = {}) {
const assistantsConfig = config.endpoints[EModelEndpoint.assistants];
const parsedConfig = assistantEndpointSchema.parse(assistantsConfig);
if (assistantsConfig.supportedIds?.length && assistantsConfig.excludedIds?.length) {
@@ -19,12 +31,6 @@ function assistantsConfigSetup(config) {
);
}
- const prevConfig = config.endpoints[EModelEndpoint.azureOpenAI]?.assistants
- ? {
- capabilities: [Capabilities.tools, Capabilities.actions, Capabilities.code_interpreter],
- }
- : {};
-
return {
...prevConfig,
retrievalModels: parsedConfig.retrievalModels,
@@ -37,4 +43,4 @@ function assistantsConfigSetup(config) {
};
}
-module.exports = { assistantsConfigSetup };
+module.exports = { azureAssistantsDefaults, assistantsConfigSetup };
diff --git a/client/src/data-provider/mutations.ts b/client/src/data-provider/mutations.ts
index a38ff09a33..bada848247 100644
--- a/client/src/data-provider/mutations.ts
+++ b/client/src/data-provider/mutations.ts
@@ -315,8 +315,7 @@ export const useCreateAssistantMutation = (
return options?.onSuccess?.(newAssistant, variables, context);
}
- const currentAssistants = listRes.data;
- currentAssistants.push(newAssistant);
+ const currentAssistants = [newAssistant, ...JSON.parse(JSON.stringify(listRes.data))];
queryClient.setQueryData<AssistantListResponse>([QueryKeys.assistants, defaultOrderQuery], {
...listRes,