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

cosmosdbnosql: Added Cosmos DB NoSQL Semantic Cache Integration with tests and jupyter notebook #24424

Merged
merged 73 commits into from
Dec 17, 2024

Conversation

gsa9989
Copy link
Contributor

@gsa9989 gsa9989 commented Jul 19, 2024

  • Added Cosmos DB NoSQL Semantic Cache Integration with tests and jupyter notebook

Copy link

vercel bot commented Jul 19, 2024

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

Name Status Preview Comments Updated (UTC)
langchain ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 2:33am

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. community Related to langchain-community 🤖:improvement Medium size change to existing code to handle new use-cases labels Jul 19, 2024
@gsa9989
Copy link
Contributor Author

gsa9989 commented Aug 1, 2024

@ccurme can you please review this PR

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Aug 7, 2024
@jcodella
Copy link

Friendly ping @ccurme for a review here

Copy link
Collaborator

@ccurme ccurme left a comment

Choose a reason for hiding this comment

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

Thanks for the ping.

See our contributing guidelines for how to format and lint code locally for future commits. I ran the formatter myself for now but there are still some type issues, would you mind taking a look? https://github.com/langchain-ai/langchain/actions/runs/10582689581/job/29323028501?pr=24424


The PR summary mentions a notebook, but I don't see any updates to documentation here. I think this would be good to add, otherwise the new cache will not be discoverable. If you edit docs/docs/integrations/llm_caching.ipynb, it will get built into the docs preview here. Let me know if you have any questions!

libs/community/langchain_community/cache.py Outdated Show resolved Hide resolved
libs/community/langchain_community/cache.py Outdated Show resolved Hide resolved
@aayush3011
Copy link
Contributor

Friendly ping @ccurme @baskaryan @isahers1 for a review here.

Comment on lines 1930 to 1932
"%%time\n",
"# The first time, it is not yet in cache, so it should take longer\n",
"llm.invoke(\"Tell me a joke\")"
Copy link
Collaborator

Choose a reason for hiding this comment

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

(nit) Could be worth running these cells to demonstrate the speedup.

@@ -2102,7 +2106,7 @@ def __init__(
ef_construction: int = 64,
ef_search: int = 40,
score_threshold: Optional[float] = None,
application_name: str = "LANGCHAIN_CACHING_PYTHON",
application_name: str = "LangChain-CDBNoSQL-SemanticCache-Python",
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Couldn't this break user workflows?
  2. What is the motivation for this change? We have AzureCosmosDBSemanticCache and AzureCosmosDBNoSqlSemanticCache separately, but then we are specifying NoSQL here.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just a name change, this should not break any workflows. This user agent is being used for tracking purposes only. We want to have it in this pattern, as Azure CosmosDB is integrated in various AI frameworks (microsoft internal and external), and we want to create dashboards to track the usage using these user agents.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes but if someone is using the default application_name, after this update the name will change, right? Even if it's just telemetry, I'm not sure we want to change this for users without warning.

It's OK to make such a change if important, but users are already free to specify application_name however they like-- why is it important to change the default here? Let me know if I'm misunderstanding.

Copy link
Contributor

Choose a reason for hiding this comment

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

Because we have seen that a lot of users are not specifying the application_name, and we can only see default value in our telemetry. So, that's the reason for this update as we can keep the application_name consistent across all our integrations.

from azure.cosmos import ContainerProxy, CosmosClient
from azure.identity import ClientSecretCredential

USER_AGENT = ("LlamaIndex-CDBNoSql-VectorStore-Python",)
Copy link
Collaborator

Choose a reason for hiding this comment

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

LlamaIndex?

@aayush3011
Copy link
Contributor

@ccurme Hey, apologies for the delay on the PR—it fell through the cracks. I've addressed all the comments, and it's ready for review. Please take a look when you have a chance. Thanks!

@aayush3011
Copy link
Contributor

Friendly ping @ccurme @baskaryan @isahers1 for a review here.

@aayush3011
Copy link
Contributor

Friendly ping @efriis @ccurme @baskaryan for a final review here.

@ccurme
Copy link
Collaborator

ccurme commented Dec 16, 2024

@aayush3011 It looks like there are some merge conflicts, are you able to take a look?

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Dec 17, 2024
@ccurme ccurme merged commit cdf6202 into langchain-ai:master Dec 17, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community 🤖:improvement Medium size change to existing code to handle new use-cases lgtm PR looks good. Use to confirm that a PR is ready for merging. size:XL This PR changes 500-999 lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants