DylanASHillier commited on
Commit
b35c986
1 Parent(s): e64599a

adds caching

Browse files
Files changed (1) hide show
  1. streamlit.py +15 -9
streamlit.py CHANGED
@@ -285,6 +285,7 @@ QUERY_MESSAGES: list[tuple[Roles, str]] = [
285
 
286
 
287
  # pylint: enable=line-too-long
 
288
  async def retrieve_docs(
289
  query: str, query_filter: dict[str, str]) -> list[docstore.Document]:
290
  # """Retrieves documents for a query
@@ -388,7 +389,7 @@ for page in PAGES:
388
  workable_customers.append(href)
389
 
390
  # workable_customers
391
- @st.cache
392
  def get_paragraphs_workable(url):
393
  r = requests.get(url=url, headers=headers)
394
 
@@ -417,14 +418,19 @@ def loop(input):
417
  input = clean_text(input)
418
  return input
419
 
420
- workable_case_studies = []
421
- # for customer in customers:
422
- # TODO(fix)
423
- for customer in workable_customers:
424
- url = customer
425
- workable_case_studies.append((url,loop('<join>'.join(get_paragraphs_workable(customer)[4:][:-4])))) # First few paragraphs are boiler plate
426
- # TODO Some additional filtering is still needed especially towards the end. We should probably discard things that are not in the main body.
427
- # workable_case_studies
 
 
 
 
 
428
 
429
 
430
  # """## App logic"""
 
285
 
286
 
287
  # pylint: enable=line-too-long
288
+ @st.cache_data
289
  async def retrieve_docs(
290
  query: str, query_filter: dict[str, str]) -> list[docstore.Document]:
291
  # """Retrieves documents for a query
 
389
  workable_customers.append(href)
390
 
391
  # workable_customers
392
+ @st.cache_data
393
  def get_paragraphs_workable(url):
394
  r = requests.get(url=url, headers=headers)
395
 
 
418
  input = clean_text(input)
419
  return input
420
 
421
+ @st.cache_data
422
+ def get_case_studies():
423
+ workable_case_studies = []
424
+ # for customer in customers:
425
+ # TODO(fix)
426
+ for customer in workable_customers:
427
+ url = customer
428
+ workable_case_studies.append((url,loop('<join>'.join(get_paragraphs_workable(customer)[4:][:-4])))) # First few paragraphs are boiler plate
429
+ # TODO Some additional filtering is still needed especially towards the end. We should probably discard things that are not in the main body.
430
+ # workable_case_studies
431
+ return workable_case_studies
432
+
433
+ workable_case_studies = get_case_studies()
434
 
435
 
436
  # """## App logic"""