gpaasch commited on
Commit
21d0c24
·
1 Parent(s): ec82b9a

1. Added text input processing function

Browse files

2. Added submit button event handler
3. Updated clear button to clear text input
4. Maintained existing voice functionality
5. Used same response formatting

Files changed (1) hide show
  1. src/app.py +37 -2
src/app.py CHANGED
@@ -550,11 +550,46 @@ with gr.Blocks(
550
  )
551
 
552
  clear_btn.click(
553
- fn=lambda: (None, ""), # Clear both chat and transcription
554
- outputs=[chatbot, transcript_box],
555
  queue=False
556
  )
557
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  # Add footer with social links
559
  gr.Markdown("""
560
  ---
 
550
  )
551
 
552
  clear_btn.click(
553
+ fn=lambda: (None, "", ""),
554
+ outputs=[chatbot, transcript_box, text_input],
555
  queue=False
556
  )
557
 
558
+ def process_text_input(text, history):
559
+ """Process text input and generate response."""
560
+ if not text:
561
+ return history
562
+
563
+ try:
564
+ # Process the symptoms
565
+ diagnosis_query = f"""
566
+ Based on these symptoms: '{text}'
567
+ Provide relevant ICD-10 codes and diagnostic questions.
568
+ Focus on clinical implications.
569
+ """
570
+ response = symptom_index.as_query_engine().query(diagnosis_query)
571
+
572
+ # Format and return chat messages
573
+ return history + [
574
+ {"role": "user", "content": text},
575
+ {"role": "assistant", "content": format_response_for_user({
576
+ "diagnoses": [],
577
+ "confidences": [],
578
+ "follow_up": str(response)
579
+ })}
580
+ ]
581
+
582
+ except Exception as e:
583
+ print(f"Text processing error: {str(e)}")
584
+ return history
585
+
586
+ submit_btn.click(
587
+ fn=process_text_input,
588
+ inputs=[text_input, chatbot],
589
+ outputs=chatbot,
590
+ queue=True
591
+ )
592
+
593
  # Add footer with social links
594
  gr.Markdown("""
595
  ---