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

feat(azure-cosmosdb): add session context and retrieve all sessions for a user #7242

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

Conversation

sinedied
Copy link
Contributor

@sinedied sinedied commented Nov 22, 2024

  • Added generic context object saved along the session. This can be used for example to give a title or save any additional properties along with a session.
  • Added method to retrieve all sessions for a user (without the messages)
  • Update to latest CosmosDB SDK (had to fix a few types in vector search integrations)

@jacoblee93 Not directly related to the PR, but I've found some memory integration that uses RunnableWithMessageHistory like ours, and other using BufferMemory which one is the recommended approach? Thanks

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. auto:improvement Medium size change to existing code to handle new use-cases auto:question A specific question about the codebase, product, project, or how to use a feature labels Nov 22, 2024
Copy link

vercel bot commented Nov 22, 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 💬 Add feedback Nov 29, 2024 11:24am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Nov 29, 2024 11:24am

Copy link
Contributor

@aditishree1 aditishree1 left a comment

Choose a reason for hiding this comment

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

nit: Should we add this in example or doc-comment to let the user know that they have the option to add context in input?

Otherwise, this PR LGTM.

@aditishree1
Copy link
Contributor

hey @sinedied, Jacob suggested to prefer RunnableWithMessageHistory.
#7057 (comment)

@sinedied
Copy link
Contributor Author

nit: Should we add this in example or doc-comment to let the user know that they have the option to add context in input?

Otherwise, this PR LGTM.

Good callout! I'll update the example with the new methods.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Nov 25, 2024
@sinedied
Copy link
Contributor Author

@aditishree1 I completed the code example with the new APIs usage.

I also had to fix a few types in the vector search integration due to the updated Cosmos SDK.

@jacoblee93
Copy link
Collaborator

which one is the recommended approach?

We have been leaning more and more on LangGraph as the memory abstraction of choice (you are defining a state with whatever keys you want) but if you need to stay in LangChain then RunnableWithMessageHistory

@jacoblee93 jacoblee93 changed the title azure-cosmosdb[minor]: add session context and retrieve all sessions for a user feat(azure-cosmosdb): add session context and retrieve all sessions for a user Nov 25, 2024
@@ -195,7 +197,7 @@ export class AzureCosmosDBNoSQLVectorStore extends VectorStore {
{
path: "/vector",
type: "quantizedFlat",
},
} as VectorIndex,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe as const works but not a huge deal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried it but it still complained 😞

@jacoblee93 jacoblee93 added the question Further information is requested label Nov 25, 2024
@sinedied
Copy link
Contributor Author

@jacoblee93 @aditishree1 I've reworked how the helper methods works so it makes more sense, and fixed handling of existing context in a session.

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 auto:question A specific question about the codebase, product, project, or how to use a feature question Further information is requested size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants