John Graham Reynolds commited on
Commit
c1c75a4
·
1 Parent(s): e49ec86

ignore hashing the already cached embeddings arg

Browse files
Files changed (1) hide show
  1. chain.py +4 -2
chain.py CHANGED
@@ -57,12 +57,14 @@ class ChainBuilder:
57
 
58
  # you cannot directly use @st.cache_resource on a method (function within a class) that has a self argument.
59
  # This is because Streamlit's caching mechanism relies on hashing the function's code and input parameters, and the self argument represents the instance of the class, which is not hashable by default.
 
 
60
  @st.cache_resource # cache the Databricks vector store retriever
61
- def get_and_cache_retriever(endpoint, index_name, embeddings, search_kwargs):
62
  vector_search_as_retriever = DatabricksVectorSearch(
63
  endpoint=endpoint,
64
  index_name=index_name,
65
- embedding=embeddings,
66
  text_column="name",
67
  columns=["name", "description"],
68
  ).as_retriever(search_kwargs=search_kwargs)
 
57
 
58
  # you cannot directly use @st.cache_resource on a method (function within a class) that has a self argument.
59
  # This is because Streamlit's caching mechanism relies on hashing the function's code and input parameters, and the self argument represents the instance of the class, which is not hashable by default.
60
+ # 'Cannot hash argument 'embeddings' (of type `langchain_huggingface.embeddings.huggingface.HuggingFaceEmbeddings`) in 'get_and_cache_retriever''
61
+ # this is fine, we are caching the entire function above for embeddings, so recalling it entirely is fast. We _embeddings to not ignore hashing this argument
62
  @st.cache_resource # cache the Databricks vector store retriever
63
+ def get_and_cache_retriever(endpoint, index_name, _embeddings, search_kwargs):
64
  vector_search_as_retriever = DatabricksVectorSearch(
65
  endpoint=endpoint,
66
  index_name=index_name,
67
+ embedding=_embeddings,
68
  text_column="name",
69
  columns=["name", "description"],
70
  ).as_retriever(search_kwargs=search_kwargs)