BtB-ExpC commited on
Commit
3d125f7
·
1 Parent(s): 091ba63

making run_with_diagnosis completely async

Browse files
chains/exercises/run_fluster_with_diagnosis.py CHANGED
@@ -315,4 +315,14 @@ def build_fluster_text(ex_list: list[Exercise]) -> str:
315
  f" Correct answer: {ex.correct_answer_id}\n"
316
  f" Explanation: {ex.explanation}\n\n"
317
  )
318
- return "\n".join(lines)
 
 
 
 
 
 
 
 
 
 
 
315
  f" Correct answer: {ex.correct_answer_id}\n"
316
  f" Explanation: {ex.explanation}\n\n"
317
  )
318
+ return "\n".join(lines)
319
+
320
+ async def run_fluster_with_diagnosis(
321
+ user_input_text: str,
322
+ model_choice_1: str,
323
+ model_choice_2: str
324
+ ) -> Tuple[str, str, str, str, str, str, str, str]:
325
+ """
326
+ Async entrypoint for the UI or external calls.
327
+ """
328
+ return await _async_fluster_with_diagnosis(user_input_text, model_choice_1, model_choice_2)
main.py CHANGED
@@ -175,26 +175,13 @@ with gr.Blocks() as interface:
175
  model_2: str,
176
  include_diagnosis: bool
177
  ):
178
- """
179
- Decide how to run the fluster generation.
180
- If include_diagnosis=False, we do all 4 tracks, no diagnosing/fixing.
181
- If include_diagnosis=True, we ONLY do tracks 1 & 3, then parse+diagnose+fix them.
182
- We'll then return 8 values:
183
- (track1, track2, track3, track4, diag1, diag3, fix1, fix3)
184
- """
185
-
186
  if not include_diagnosis:
187
- # => run the original pipeline that yields 4 parallel flusters
188
- # and do NOT parse/diagnose/fix anything.
189
  generator = run_fluster_no_diagnosis(user_input, model_1, model_2)
190
- # Get the last result from the generator
191
  final_results = ["", "", "", ""]
192
  async for results in generator:
193
  final_results = results
194
  return (*final_results, "", "", "", "")
195
  else:
196
- # => run only track0 & track2 (i.e. track 1 & track3 in the UI),
197
- # parse them for 3 exercises each, diagnose, fix
198
  return await run_fluster_with_diagnosis(user_input, model_1, model_2)
199
 
200
 
 
175
  model_2: str,
176
  include_diagnosis: bool
177
  ):
 
 
 
 
 
 
 
 
178
  if not include_diagnosis:
 
 
179
  generator = run_fluster_no_diagnosis(user_input, model_1, model_2)
 
180
  final_results = ["", "", "", ""]
181
  async for results in generator:
182
  final_results = results
183
  return (*final_results, "", "", "", "")
184
  else:
 
 
185
  return await run_fluster_with_diagnosis(user_input, model_1, model_2)
186
 
187