Skip to content

Commit

Permalink
🤖 fix: Azure Agents after Upstream Breaking Change (#5571)
Browse files Browse the repository at this point in the history
* 🤖 fix: Azure Agents after Upstream Breaking Change

* chore: bump @langchain/core & @librechat/agents

* fix: correct formatting in assistant actions update logic and use correctly filtered actions variable

* fix: linting errors
  • Loading branch information
danny-avila authored Jan 31, 2025
1 parent e1a6268 commit 6920e23
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 471 deletions.
4 changes: 2 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
"@keyv/mongo": "^2.1.8",
"@keyv/redis": "^2.8.1",
"@langchain/community": "^0.3.14",
"@langchain/core": "^0.3.18",
"@langchain/core": "^0.3.37",
"@langchain/google-genai": "^0.1.7",
"@langchain/google-vertexai": "^0.1.8",
"@langchain/textsplitters": "^0.1.0",
"@librechat/agents": "^1.9.98",
"@librechat/agents": "^2.0.0",
"@waylaidwanderer/fetch-event-source": "^3.0.1",
"axios": "^1.7.7",
"bcryptjs": "^2.4.3",
Expand Down
16 changes: 3 additions & 13 deletions api/server/routes/assistants/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,7 @@ router.post('/:assistant_id', async (req, res) => {
if (!assistant_data) {
assistantUpdateData.user = req.user.id;
}
promises.push(
updateAssistantDoc(
{ assistant_id },
assistantUpdateData,
)
);
promises.push(updateAssistantDoc({ assistant_id }, assistantUpdateData));

// Only update user field for new actions
const actionUpdateData = { metadata, assistant_id };
Expand Down Expand Up @@ -191,16 +186,11 @@ router.delete('/:assistant_id/:action_id/:model', async (req, res) => {

const promises = [];
// Only update user field if assistant document doesn't exist
const assistantUpdateData = { actions };
const assistantUpdateData = { actions: updatedActions };
if (!assistant_data) {
assistantUpdateData.user = req.user.id;
}
promises.push(
updateAssistantDoc(
{ assistant_id },
assistantUpdateData,
),
);
promises.push(updateAssistantDoc({ assistant_id }, assistantUpdateData));
promises.push(deleteAction({ action_id }));

await Promise.all(promises);
Expand Down
9 changes: 4 additions & 5 deletions config/list-users.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
const path = require('path');
require('module-alias')({ base: path.resolve(__dirname, '..', 'api') });
const { askQuestion, silentExit } = require('./helpers');
const connect = require('./connect');
const User = require('../api/models/User');

const listUsers = async () => {
try {
await connect();
const users = await User.find({}, 'email provider avatar username name createdAt');

console.log('\nUser List:');
console.log('----------------------------------------');
users.forEach(user => {
users.forEach((user) => {
console.log(`Email: ${user.email}`);
console.log(`Username: ${user.username || 'N/A'}`);
console.log(`Name: ${user.name || 'N/A'}`);
console.log(`Provider: ${user.provider || 'email'}`);
console.log(`Created: ${user.createdAt}`);
console.log('----------------------------------------');
});

console.log(`\nTotal Users: ${users.length}`);
process.exit(0);
} catch (err) {
Expand All @@ -28,4 +27,4 @@ const listUsers = async () => {
}
};

listUsers();
listUsers();
35 changes: 17 additions & 18 deletions config/reset-password.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,57 @@
const path = require('path');
require('module-alias')({ base: path.resolve(__dirname, '..', 'api') });
const { askQuestion, silentExit } = require('./helpers');
const connect = require('./connect');
const User = require('../api/models/User');
const bcrypt = require('bcryptjs');
const readline = require('readline');
require('module-alias')({ base: path.resolve(__dirname, '..', 'api') });
const User = require('../api/models/User');
const connect = require('./connect');

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
output: process.stdout,
});

const question = (query) => new Promise((resolve) => rl.question(query, resolve));

const resetPassword = async () => {
try {
await connect();

const email = await question('Enter user email: ');
const user = await User.findOne({ email });

if (!user) {
console.error('User not found!');
process.exit(1);
}

let validPassword = false;
let newPassword;

while (!validPassword) {
newPassword = await question('Enter new password: ');
if (newPassword.length < 8) {
console.log('Password must be at least 8 characters! Please try again.');
continue;
console.log('Password must be at least 8 characters! Please try again.');
continue;
}

const confirmPassword = await question('Confirm new password: ');
if (newPassword !== confirmPassword) {
console.log('Passwords do not match! Please try again.');
continue;
console.log('Passwords do not match! Please try again.');
continue;
}

validPassword = true;
}

const salt = await bcrypt.genSalt(10);
const hashedPassword = await bcrypt.hash(newPassword, salt);

await User.updateOne(
{ email },
{
{
password: hashedPassword,
passwordVersion: Date.now() // Invalidate old sessions
}
passwordVersion: Date.now(), // Invalidate old sessions
},
);

console.log('Password successfully reset!');
Expand All @@ -65,4 +64,4 @@ const resetPassword = async () => {
}
};

resetPassword();
resetPassword();
Loading

0 comments on commit 6920e23

Please sign in to comment.