Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add session context for a user mongodb #7436

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

crisjy
Copy link
Contributor

@crisjy crisjy commented Dec 27, 2024

Fixes # (issue)

Copy link

vercel bot commented Dec 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jan 9, 2025 3:03am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Jan 9, 2025 3:03am

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 27, 2024
@dosubot dosubot bot added the auto:improvement Medium size change to existing code to handle new use-cases label Dec 27, 2024
Copy link
Collaborator

@jacoblee93 jacoblee93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me!

@sinedied do you mind giving this a look?

@jacoblee93 jacoblee93 added question Further information is requested lgtm PRs that are ready to be merged as-is labels Jan 2, 2025
Copy link
Contributor

@sinedied sinedied left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @crisjy !
The context handling looks fine here, but you're missing user handling, which is needed to list/delete sessions otherwise you have no distinction of users.

What we did in the other CosmosDB implementation is make userId parameter optional in the DB options and set it to anonymous by default to keep compatibility with other implementation (or when user handling is not needed).

{ upsert: true }
);
} catch (error) {
console.log("Error setting context", error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to throw so these errors can be identified

try {
await this.collection.deleteMany({});
} catch (error) {
console.log("Error clearing sessions:", error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to throw so these errors can be identified

async clearAllSessions() {
await this.initialize();
try {
await this.collection.deleteMany({});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would delete all sessions for all users, which might not be the intended behavior... I think you missed the user handling here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases lgtm PRs that are ready to be merged as-is question Further information is requested size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants