Spaces:
Running
Running
submit button wasn't working
Browse files- .gradio/certificate.pem +31 -0
- src/app.py +32 -55
.gradio/certificate.pem
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----BEGIN CERTIFICATE-----
|
2 |
+
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
3 |
+
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
4 |
+
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
|
5 |
+
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
|
6 |
+
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
|
7 |
+
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
|
8 |
+
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
|
9 |
+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
|
10 |
+
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
|
11 |
+
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
|
12 |
+
B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
|
13 |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4Ui0/1lvh+wjChP4kqKOJ2qxq
|
28 |
+
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
|
29 |
+
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
|
30 |
+
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
|
31 |
+
-----END CERTIFICATE-----
|
src/app.py
CHANGED
@@ -552,66 +552,43 @@ with gr.Blocks(theme="default") as demo:
|
|
552 |
def process_text_input(text, history):
|
553 |
"""Process text input with memory management."""
|
554 |
if not text:
|
555 |
-
return history
|
556 |
|
557 |
-
|
558 |
-
|
559 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
560 |
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
"diagnoses": [],
|
577 |
-
"confidences": [],
|
578 |
-
"follow_up": str(response)[:1000] # Limit response length
|
579 |
-
})}
|
580 |
-
]
|
581 |
|
|
|
582 |
submit_btn.click(
|
583 |
fn=process_text_input,
|
584 |
inputs=[text_input, chatbot],
|
585 |
-
outputs=chatbot,
|
586 |
queue=True
|
|
|
|
|
|
|
|
|
|
|
587 |
)
|
588 |
-
|
589 |
-
# Add footer with social links
|
590 |
-
gr.Markdown("""
|
591 |
-
---
|
592 |
-
### 👋 About the Creator
|
593 |
-
|
594 |
-
Hi! I'm Graham Paasch, an experienced technology professional!
|
595 |
-
|
596 |
-
🎥 **Check out my YouTube channel** for more tech content:
|
597 |
-
[Subscribe to my channel](https://www.youtube.com/channel/UCg3oUjrSYcqsL9rGk1g_lPQ)
|
598 |
-
|
599 |
-
💼 **Looking for a skilled developer?**
|
600 |
-
I'm currently seeking new opportunities! View my experience and connect on [LinkedIn](https://www.linkedin.com/in/grahampaasch/)
|
601 |
-
|
602 |
-
⭐ If you found this tool helpful, please consider:
|
603 |
-
- Subscribing to my YouTube channel
|
604 |
-
- Connecting on LinkedIn
|
605 |
-
- Sharing this tool with others in healthcare tech
|
606 |
-
""")
|
607 |
-
|
608 |
-
def process_symptoms(symptoms: str):
|
609 |
-
"""Convert symptoms to ICD codes using the configured LLM"""
|
610 |
-
try:
|
611 |
-
# Use the configured LLM to process symptoms
|
612 |
-
response = llm.complete(
|
613 |
-
f"Convert these symptoms to ICD-10 codes: {symptoms}"
|
614 |
-
)
|
615 |
-
return {"icd_codes": response.text, "status": "success"}
|
616 |
-
except Exception as e:
|
617 |
-
return {"error": str(e), "status": "error"}
|
|
|
552 |
def process_text_input(text, history):
|
553 |
"""Process text input with memory management."""
|
554 |
if not text:
|
555 |
+
return history, "" # Return tuple to clear input
|
556 |
|
557 |
+
try:
|
558 |
+
# Process the symptoms
|
559 |
+
diagnosis_query = f"""
|
560 |
+
Based on these symptoms: '{text}'
|
561 |
+
Provide relevant ICD-10 codes and diagnostic questions.
|
562 |
+
Focus on clinical implications.
|
563 |
+
Limit response to 1000 characters.
|
564 |
+
"""
|
565 |
+
response = symptom_index.as_query_engine().query(diagnosis_query)
|
566 |
|
567 |
+
# Clean up memory
|
568 |
+
cleanup_memory()
|
569 |
+
|
570 |
+
new_history = history + [
|
571 |
+
{"role": "user", "content": text},
|
572 |
+
{"role": "assistant", "content": format_response_for_user({
|
573 |
+
"diagnoses": [],
|
574 |
+
"confidences": [],
|
575 |
+
"follow_up": str(response)[:1000]
|
576 |
+
})}
|
577 |
+
]
|
578 |
+
return new_history, "" # Return empty string to clear input
|
579 |
+
except Exception as e:
|
580 |
+
print(f"Error processing text: {str(e)}")
|
581 |
+
return history, text # Keep text on error
|
|
|
|
|
|
|
|
|
|
|
582 |
|
583 |
+
# Update the submit button handler
|
584 |
submit_btn.click(
|
585 |
fn=process_text_input,
|
586 |
inputs=[text_input, chatbot],
|
587 |
+
outputs=[chatbot, text_input], # Add text_input to outputs
|
588 |
queue=True
|
589 |
+
).then( # Chain cleanup
|
590 |
+
fn=cleanup_memory,
|
591 |
+
inputs=None,
|
592 |
+
outputs=None,
|
593 |
+
queue=False
|
594 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|