lingyit1108 commited on
Commit
00561ea
1 Parent(s): 23e06a5

added code to check time cost

Browse files
Files changed (2) hide show
  1. main.py +9 -0
  2. pages/3_app.py +8 -3
main.py CHANGED
@@ -12,6 +12,7 @@ from llama_index.embeddings import HuggingFaceEmbedding
12
  from trulens_eval import Tru
13
 
14
  from utils import get_prebuilt_trulens_recorder
 
15
 
16
  openai.api_key = utils.get_openai_api_key()
17
 
@@ -19,6 +20,7 @@ def main():
19
 
20
  if not os.path.exists("./default.sqlite"):
21
 
 
22
  file_ls_str = ", ".join(os.listdir("./raw_documents"))
23
  print(f"File list: {file_ls_str}")
24
  print("")
@@ -37,6 +39,7 @@ def main():
37
  embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
38
 
39
  print("Creating vector store ..")
 
40
  service_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)
41
  index = VectorStoreIndex.from_documents([document], service_context=service_context)
42
 
@@ -72,6 +75,12 @@ def main():
72
  records.to_csv("./results/records.csv", index=False)
73
 
74
  print(tru.db.engine.url.render_as_string(hide_password=False))
 
 
 
 
 
 
75
  # tru.run_dashboard()
76
 
77
  if __name__ == "__main__":
 
12
  from trulens_eval import Tru
13
 
14
  from utils import get_prebuilt_trulens_recorder
15
+ import time
16
 
17
  openai.api_key = utils.get_openai_api_key()
18
 
 
20
 
21
  if not os.path.exists("./default.sqlite"):
22
 
23
+ start_time = time.time()
24
  file_ls_str = ", ".join(os.listdir("./raw_documents"))
25
  print(f"File list: {file_ls_str}")
26
  print("")
 
39
  embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
40
 
41
  print("Creating vector store ..")
42
+ print("time spent:", time.time() - start_time)
43
  service_context = ServiceContext.from_defaults(llm=llm, embed_model=embed_model)
44
  index = VectorStoreIndex.from_documents([document], service_context=service_context)
45
 
 
75
  records.to_csv("./results/records.csv", index=False)
76
 
77
  print(tru.db.engine.url.render_as_string(hide_password=False))
78
+
79
+ end_time = time.time()
80
+ time_spent_mins = (end_time - start_time) / 60
81
+ with open("./results/time_cost.txt", "w") as fp:
82
+ fp.write(f"Takes {int(time_spent_mins)} mins to create llm evaluation.")
83
+
84
  # tru.run_dashboard()
85
 
86
  if __name__ == "__main__":
pages/3_app.py CHANGED
@@ -4,8 +4,13 @@ import os
4
  try:
5
  raw_docs_files = ", ".join(os.listdir("./raw_documents"))
6
  curr_directory_files = ", ".join(os.listdir("."))
7
- file_ls_str = raw_docs_files + "\n\n" + curr_directory_files
 
 
 
 
 
8
  except:
9
- file_ls_str = "NA"
10
 
11
- st.write(f"Hello World! File list: {file_ls_str}")
 
4
  try:
5
  raw_docs_files = ", ".join(os.listdir("./raw_documents"))
6
  curr_directory_files = ", ".join(os.listdir("."))
7
+
8
+ with open("./results/time_cost.txt", "r") as fp:
9
+ time_cost_str = fp.read()
10
+
11
+ system_update = raw_docs_files + "\n\n" + curr_directory_files + "\n\n" + time_cost_str
12
+
13
  except:
14
+ system_update = "NA"
15
 
16
+ st.write(f"Hello World! File list: {system_update}")