vikramvasudevan commited on
Commit
7d0bec7
·
verified ·
1 Parent(s): 3b530b8

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. graph.py +24 -8
graph.py CHANGED
@@ -92,8 +92,8 @@ class SheamiState(TypedDict):
92
  process_desc: str
93
  units_processed: int
94
  units_total: int
95
- overall_units_processed : int
96
- overall_units_total : int
97
 
98
 
99
  import re
@@ -163,7 +163,7 @@ def fn_init_node(state: SheamiState):
163
  state["units_total"] = 0
164
  state["process_desc"] = ""
165
  state["overall_units_processed"] = 0
166
- state["overall_units_total"] = 6 # 6 steps totally
167
 
168
  return state
169
 
@@ -174,8 +174,19 @@ def reset_process_desc(state: SheamiState, process_desc: str):
174
  state["units_total"] = 0
175
  return state
176
 
 
177
  async def fn_increment_index_node(state: SheamiState):
178
  state["current_index"] += 1
 
 
 
 
 
 
 
 
 
 
179
  return state
180
 
181
 
@@ -222,11 +233,8 @@ def fn_is_report_available_to_process(state: SheamiState) -> str:
222
  return "done"
223
 
224
 
225
- async def fn_testname_standardizer_node(state: SheamiState):
226
- logger.info("%s| Standardizing Test Names: started", state["thread_id"])
227
- state["messages"].append("Standardizing Test Names: started")
228
- # collect unique names
229
- unique_names = list(
230
  {
231
  result.test_name
232
  for report in state["standardized_reports"]
@@ -234,6 +242,13 @@ async def fn_testname_standardizer_node(state: SheamiState):
234
  }
235
  )
236
 
 
 
 
 
 
 
 
237
  # run through LLM
238
  response = testname_standardizer_chain.invoke({"test_names": unique_names})
239
  raw_text = response.content
@@ -251,6 +266,7 @@ async def fn_testname_standardizer_node(state: SheamiState):
251
  for result in report.lab_results:
252
  result.test_name = normalization_map.get(result.test_name, result.test_name)
253
  logger.info("%s| Standardizing Test Names: finished", state["thread_id"])
 
254
  state["messages"].append("Standardizing Test Names: finished")
255
  return state
256
 
 
92
  process_desc: str
93
  units_processed: int
94
  units_total: int
95
+ overall_units_processed: int
96
+ overall_units_total: int
97
 
98
 
99
  import re
 
163
  state["units_total"] = 0
164
  state["process_desc"] = ""
165
  state["overall_units_processed"] = 0
166
+ state["overall_units_total"] = 6 # 6 steps totally
167
 
168
  return state
169
 
 
174
  state["units_total"] = 0
175
  return state
176
 
177
+
178
  async def fn_increment_index_node(state: SheamiState):
179
  state["current_index"] += 1
180
+ total_reports = len(state["uploaded_reports"])
181
+ try:
182
+ report_file_name = state["uploaded_reports"][
183
+ state["current_index"]
184
+ ].report_file_name
185
+ state["process_desc"] = (
186
+ f"Standardizing {state["current_index"]+1} of {total_reports} reports - {report_file_name} ..."
187
+ )
188
+ except:
189
+ pass
190
  return state
191
 
192
 
 
233
  return "done"
234
 
235
 
236
+ def get_unique_test_names(state: SheamiState):
237
+ return list(
 
 
 
238
  {
239
  result.test_name
240
  for report in state["standardized_reports"]
 
242
  }
243
  )
244
 
245
+
246
+ async def fn_testname_standardizer_node(state: SheamiState):
247
+ logger.info("%s| Standardizing Test Names: started", state["thread_id"])
248
+ state["messages"].append("Standardizing Test Names: started")
249
+ # collect unique names
250
+ unique_names = get_unique_test_names(state)
251
+
252
  # run through LLM
253
  response = testname_standardizer_chain.invoke({"test_names": unique_names})
254
  raw_text = response.content
 
266
  for result in report.lab_results:
267
  result.test_name = normalization_map.get(result.test_name, result.test_name)
268
  logger.info("%s| Standardizing Test Names: finished", state["thread_id"])
269
+ state["messages"].append(f"Processed {len(unique_names)} tests")
270
  state["messages"].append("Standardizing Test Names: finished")
271
  return state
272