LiamKhoaLe commited on
Commit
5298fbe
·
1 Parent(s): 3355e73

Upd syntax

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -1866,7 +1866,7 @@ def stream_chat(
1866
 
1867
  if needs_translation:
1868
  logger.info(f"[GEMINI SUPERVISOR] Detected non-English language: {original_lang}, translating...")
1869
- message = translate_text(message, target_lang="en", source_lang=original_lang)
1870
  logger.info(f"[GEMINI SUPERVISOR] Translated query: {message[:100]}...")
1871
 
1872
  # Determine final modes (respect user settings and availability)
@@ -1973,7 +1973,7 @@ def stream_chat(
1973
  for idx, sub_topic in enumerate(breakdown.get("sub_topics", []), 1):
1974
  if elapsed() >= hard_timeout - 5:
1975
  logger.warning(f"[MEDSWIN] Time limit approaching, stopping at task {idx}")
1976
- break
1977
 
1978
  task_instruction = sub_topic.get("instruction", "")
1979
  topic_name = sub_topic.get("topic", f"Topic {idx}")
@@ -1995,10 +1995,10 @@ def stream_chat(
1995
  task_instruction=task_instruction,
1996
  context=task_context if task_context else "",
1997
  system_prompt_base=base_system_prompt,
1998
- temperature=temperature,
1999
  max_new_tokens=min(max_new_tokens, 800), # Limit per task
2000
- top_p=top_p,
2001
- top_k=top_k,
2002
  penalty=penalty
2003
  )
2004
 
@@ -2010,7 +2010,7 @@ def stream_chat(
2010
  # Stream partial answer as we complete each task
2011
  partial_final = "\n\n".join(medswin_answers)
2012
  updated_history[-1]["content"] = partial_final
2013
- yield updated_history
2014
 
2015
  except Exception as e:
2016
  logger.error(f"[MEDSWIN] Task {idx} failed: {e}")
@@ -2036,7 +2036,7 @@ def stream_chat(
2036
  final_answer = '\n'.join(cleaned_lines)
2037
 
2038
  # ===== STEP 6: Finalize answer (translate, add citations, format) =====
2039
- # Translate back if needed
2040
  if needs_translation and final_answer:
2041
  logger.info(f"[GEMINI SUPERVISOR] Translating response back to {original_lang}...")
2042
  final_answer = translate_text(final_answer, target_lang=original_lang, source_lang="en")
@@ -2121,8 +2121,8 @@ def create_demo():
2121
  type="filepath",
2122
  label="",
2123
  show_label=False,
2124
- container=False,
2125
- scale=1
2126
  )
2127
  submit_button = gr.Button("➤", elem_classes="submit-btn", scale=1)
2128
 
@@ -2130,10 +2130,10 @@ def create_demo():
2130
  recording_timer = gr.Textbox(
2131
  value="",
2132
  label="",
2133
- show_label=False,
2134
  interactive=False,
2135
  visible=False,
2136
- container=False,
2137
  elem_classes="recording-timer"
2138
  )
2139
 
 
1866
 
1867
  if needs_translation:
1868
  logger.info(f"[GEMINI SUPERVISOR] Detected non-English language: {original_lang}, translating...")
1869
+ message = translate_text(message, target_lang="en", source_lang=original_lang)
1870
  logger.info(f"[GEMINI SUPERVISOR] Translated query: {message[:100]}...")
1871
 
1872
  # Determine final modes (respect user settings and availability)
 
1973
  for idx, sub_topic in enumerate(breakdown.get("sub_topics", []), 1):
1974
  if elapsed() >= hard_timeout - 5:
1975
  logger.warning(f"[MEDSWIN] Time limit approaching, stopping at task {idx}")
1976
+ break
1977
 
1978
  task_instruction = sub_topic.get("instruction", "")
1979
  topic_name = sub_topic.get("topic", f"Topic {idx}")
 
1995
  task_instruction=task_instruction,
1996
  context=task_context if task_context else "",
1997
  system_prompt_base=base_system_prompt,
1998
+ temperature=temperature,
1999
  max_new_tokens=min(max_new_tokens, 800), # Limit per task
2000
+ top_p=top_p,
2001
+ top_k=top_k,
2002
  penalty=penalty
2003
  )
2004
 
 
2010
  # Stream partial answer as we complete each task
2011
  partial_final = "\n\n".join(medswin_answers)
2012
  updated_history[-1]["content"] = partial_final
2013
+ yield updated_history
2014
 
2015
  except Exception as e:
2016
  logger.error(f"[MEDSWIN] Task {idx} failed: {e}")
 
2036
  final_answer = '\n'.join(cleaned_lines)
2037
 
2038
  # ===== STEP 6: Finalize answer (translate, add citations, format) =====
2039
+ # Translate back if needed
2040
  if needs_translation and final_answer:
2041
  logger.info(f"[GEMINI SUPERVISOR] Translating response back to {original_lang}...")
2042
  final_answer = translate_text(final_answer, target_lang=original_lang, source_lang="en")
 
2121
  type="filepath",
2122
  label="",
2123
  show_label=False,
2124
+ container=False,
2125
+ scale=1
2126
  )
2127
  submit_button = gr.Button("➤", elem_classes="submit-btn", scale=1)
2128
 
 
2130
  recording_timer = gr.Textbox(
2131
  value="",
2132
  label="",
2133
+ show_label=False,
2134
  interactive=False,
2135
  visible=False,
2136
+ container=False,
2137
  elem_classes="recording-timer"
2138
  )
2139