mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-04 04:28:58 +00:00
community[patch]: Fixing some caching issues for AzureCosmosDBSemanticCache (#18884)
Fixing some issues for AzureCosmosDBSemanticCache - Added the entry for "AzureCosmosDBSemanticCache" which was missing in langchain/cache.py - Added application name when creating the MongoClient for the AzureCosmosDBVectorSearch, for tracking purposes. @baskaryan, can you please review this PR, we need this to go in asap. These are just small fixes which we found today in our testing.
This commit is contained in:
@@ -1879,6 +1879,7 @@ class AzureCosmosDBSemanticCache(BaseCache):
|
||||
ef_construction: int = 64,
|
||||
ef_search: int = 40,
|
||||
score_threshold: Optional[float] = None,
|
||||
application_name: str = "LANGCHAIN_CACHING_PYTHON",
|
||||
):
|
||||
"""
|
||||
Args:
|
||||
@@ -1920,6 +1921,7 @@ class AzureCosmosDBSemanticCache(BaseCache):
|
||||
(40 by default). A higher value provides better
|
||||
recall at the cost of speed.
|
||||
score_threshold: Maximum score used to filter the vector search documents.
|
||||
application_name: Application name for the client for tracking and logging
|
||||
"""
|
||||
|
||||
self._validate_enum_value(similarity, CosmosDBSimilarityType)
|
||||
@@ -1942,6 +1944,7 @@ class AzureCosmosDBSemanticCache(BaseCache):
|
||||
self.ef_search = ef_search
|
||||
self.score_threshold = score_threshold
|
||||
self._cache_dict: Dict[str, AzureCosmosDBVectorSearch] = {}
|
||||
self.application_name = application_name
|
||||
|
||||
def _index_name(self, llm_string: str) -> str:
|
||||
hashed_index = _hash(llm_string)
|
||||
@@ -1972,6 +1975,7 @@ class AzureCosmosDBSemanticCache(BaseCache):
|
||||
namespace=namespace,
|
||||
embedding=self.embedding,
|
||||
index_name=index_name,
|
||||
application_name=self.application_name,
|
||||
)
|
||||
|
||||
# create index for the vectorstore
|
||||
|
Reference in New Issue
Block a user