John Graham Reynolds commited on
Commit
4abddf8
·
1 Parent(s): f45b463

try to change path to css file and add newer, non-experimental decorator for caching

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -31,12 +31,13 @@ EXAMPLE_PROMPTS = [
31
  ]
32
 
33
  TITLE = "VUMC Chatbot"
34
- DESCRIPTION="""Welcome to the first generation Vanderbilt AI assistant! This AI assistant is built atop the Databricks DBRX large language model
35
  and is augmented with additional organization-specific knowledge. Specifically, it has been preliminarily augmented with knowledge of Vanderbilt University Medical Center
36
  terms like **Data Lake**, **EDW** (Enterprise Data Warehouse), **HCERA** (Health Care and Education Reconciliation Act), and **thousands more!** The model has **no access to PHI**.
37
  Try querying the model with any of the examples prompts below for a simple introduction to both Vanderbilt-specific and general knowledge queries. The purpose of this
38
- model is to allow VUMC employees access to an intelligent assistant that improves and expedites VUMC work. Please provide any feedback, ideas, or issues to the email: **[email protected]**.
39
- Feedback and ideas are very welcome! We hope to gradually improve this AI assistant to create a large-scale, all-inclusive tool to compliment the work of all VUMC staff."""
 
40
 
41
  GENERAL_ERROR_MSG = "An error occurred. Please refresh the page to start a new conversation."
42
 
@@ -58,7 +59,7 @@ st.markdown(DESCRIPTION)
58
  st.markdown("\n")
59
 
60
  # use this to format later
61
- with open("style.css") as css:
62
  st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
63
 
64
  if "messages" not in st.session_state:
@@ -80,7 +81,7 @@ def get_system_prompt():
80
  # make sure we cache this so that it doesnt redownload each time, hindering Space start time if sleeping
81
  # try adding this st caching decorator to ensure the embeddings class gets cached after downloading the entirety of the model
82
  # does this cache to the given folder though? It does appear to populate the folder as expected after being run
83
- @st.experimental_memo
84
  def load_embedding_model():
85
  embeddings = HuggingFaceEmbeddings(model_name="BAAI/bge-large-en", cache_folder="./langchain_cache/")
86
  return embeddings
@@ -89,6 +90,7 @@ embeddings = load_embedding_model()
89
  # instantiate the vector store for similarity search in our chain
90
  # need to make this a function and decorate it with @st.experimental_memo as above?
91
  # We are only calling this initially when the Space starts. Can we expedite this process for users when opening up this Space?
 
92
  vector_store = DatabricksVectorSearch(
93
  endpoint=VS_ENDPOINT_NAME,
94
  index_name=VS_INDEX_NAME,
 
31
  ]
32
 
33
  TITLE = "VUMC Chatbot"
34
+ DESCRIPTION="""Welcome to the first generation Vanderbilt AI assistant! \n This AI assistant is built atop the Databricks DBRX large language model
35
  and is augmented with additional organization-specific knowledge. Specifically, it has been preliminarily augmented with knowledge of Vanderbilt University Medical Center
36
  terms like **Data Lake**, **EDW** (Enterprise Data Warehouse), **HCERA** (Health Care and Education Reconciliation Act), and **thousands more!** The model has **no access to PHI**.
37
  Try querying the model with any of the examples prompts below for a simple introduction to both Vanderbilt-specific and general knowledge queries. The purpose of this
38
+ model is to allow VUMC employees access to an intelligent assistant that improves and expedites VUMC work. \n
39
+ Feedback and ideas are very welcome! Please provide any feedback, ideas, or issues to the email: **[email protected]**.
40
+ We hope to gradually improve this AI assistant to create a large-scale, all-inclusive tool to compliment the work of all VUMC staff."""
41
 
42
  GENERAL_ERROR_MSG = "An error occurred. Please refresh the page to start a new conversation."
43
 
 
59
  st.markdown("\n")
60
 
61
  # use this to format later
62
+ with open("./style.css") as css:
63
  st.markdown( f'<style>{css.read()}</style>' , unsafe_allow_html= True)
64
 
65
  if "messages" not in st.session_state:
 
81
  # make sure we cache this so that it doesnt redownload each time, hindering Space start time if sleeping
82
  # try adding this st caching decorator to ensure the embeddings class gets cached after downloading the entirety of the model
83
  # does this cache to the given folder though? It does appear to populate the folder as expected after being run
84
+ @st.cache_data # will this work here?
85
  def load_embedding_model():
86
  embeddings = HuggingFaceEmbeddings(model_name="BAAI/bge-large-en", cache_folder="./langchain_cache/")
87
  return embeddings
 
90
  # instantiate the vector store for similarity search in our chain
91
  # need to make this a function and decorate it with @st.experimental_memo as above?
92
  # We are only calling this initially when the Space starts. Can we expedite this process for users when opening up this Space?
93
+ # @st.cache_data # TODO add this in
94
  vector_store = DatabricksVectorSearch(
95
  endpoint=VS_ENDPOINT_NAME,
96
  index_name=VS_INDEX_NAME,