Ali2206 commited on
Commit
99e7b0d
·
verified ·
1 Parent(s): 6b4b480

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -283,7 +283,7 @@ def init_agent():
283
  )
284
  sampling_params = SamplingParams(
285
  temperature=0.2,
286
- max_tokens=256, # Reduced for faster streaming
287
  stop=["</s>", "[INST]"],
288
  )
289
  log_system_usage("After Load")
@@ -375,7 +375,7 @@ Patient Record Excerpt (Chunk {0} of {1}):
375
  history[-1] = {"role": "assistant", "content": chunk_response}
376
  threading.Thread(target=log_response_partial, args=(chunk_response,)).start()
377
  yield history, None, ""
378
- await asyncio.sleep(0.01) # Prevent UI blocking
379
 
380
  if chunk_response:
381
  combined_response += f"--- Analysis for Chunk {batch_idx + 1} ---\n{chunk_response}\n"
@@ -398,8 +398,8 @@ Patient Record Excerpt (Chunk {0} of {1}):
398
  threading.Thread(target=log_response_partial, args=(f"Error: {str(e)}",)).start()
399
  yield history, None, f"Error occurred during analysis: {str(e)}"
400
 
401
- send_btn.click(analyze, inputs=[msg_input, gr.State([]), file_upload], outputs=[chatbot, download_output, final_summary], _js="() => {return {streaming: true}}")
402
- msg_input.submit(analyze, inputs=[msg_input, gr.State([]), file_upload], outputs=[chatbot, download_output, final_summary], _js="() => {return {streaming: true}}")
403
  return demo
404
 
405
  if __name__ == "__main__":
 
283
  )
284
  sampling_params = SamplingParams(
285
  temperature=0.2,
286
+ max_tokens=256,
287
  stop=["</s>", "[INST]"],
288
  )
289
  log_system_usage("After Load")
 
375
  history[-1] = {"role": "assistant", "content": chunk_response}
376
  threading.Thread(target=log_response_partial, args=(chunk_response,)).start()
377
  yield history, None, ""
378
+ await asyncio.sleep(0.01)
379
 
380
  if chunk_response:
381
  combined_response += f"--- Analysis for Chunk {batch_idx + 1} ---\n{chunk_response}\n"
 
398
  threading.Thread(target=log_response_partial, args=(f"Error: {str(e)}",)).start()
399
  yield history, None, f"Error occurred during analysis: {str(e)}"
400
 
401
+ send_btn.click(analyze, inputs=[msg_input, gr.State([]), file_upload], outputs=[chatbot, download_output, final_summary])
402
+ msg_input.submit(analyze, inputs=[msg_input, gr.State([]), file_upload], outputs=[chatbot, download_output, final_summary])
403
  return demo
404
 
405
  if __name__ == "__main__":