Commit History

Update app.py
2f06f8e
verified

Prometheus799 commited on

Update app.py
7dfe3cd
verified

Prometheus799 commited on

Update requirements.txt
f429ae3
verified

Prometheus799 commited on

Update app.py
31e7a5c
verified

Prometheus799 commited on

Update requirements.txt
23b43e2
verified

Prometheus799 commited on

Update requirements.txt
f5791d7
verified

Prometheus799 commited on

Update requirements.txt
a5fbae9
verified

Prometheus799 commited on

Update app.py
c9313c6
verified

Prometheus799 commited on

import gradio as gr from transformers import pipeline # Load a free model from Hugging Face (DistilGPT2) gpt = pipeline("text-generation", model="distilgpt2") # More structured symptoms and conditions database with a basic "likelihood" conditions_db = { "fever": {"flu": 0.8, "cold": 0.7, "malaria": 0.6}, "headache": {"migraine": 0.7, "tension headache": 0.6, "dehydration": 0.5}, "fatigue": {"anemia": 0.7, "thyroid issues": 0.6, "lack of sleep": 0.8}, "cough": {"bronchitis": 0.7, "cold": 0.6, "covid-19": 0.7}, "sore throat": {"strep throat": 0.8, "flu": 0.7, "covid-19": 0.6}, } # Function to predict conditions with likelihood def predict_conditions(symptoms): possible_conditions = {} for symptom in symptoms: symptom = symptom.lower().strip() if symptom in conditions_db: for condition, likelihood in conditions_db[symptom].items(): possible_conditions[condition] = possible_conditions.get(condition, 0) + likelihood # Sort conditions by total likelihood (descending) sorted_conditions = sorted(possible_conditions.items(), key=lambda item: item[1], reverse=True) return [f"{condition} (likelihood: {likelihood:.1f})" for condition, likelihood in sorted_conditions] # Function to respond to user input def health_chat(user_input): if not user_input.strip(): return "Please enter your symptoms." symptoms = [word.strip() for word in user_input.lower().split(",")] predicted_conditions = predict_conditions(symptoms) if predicted_conditions: response = f"Based on the symptoms you described ({', '.join(symptoms)}), possible conditions from our limited database (with a basic likelihood indication) include: {', '.join(predicted_conditions)}. For more specific information and management, please consult a healthcare professional." return response else: prompt = f"""The user is describing some health concerns: "{user_input}". As a helpful AI assistant for demonstration purposes, provide a brief, general overview of potential health areas these symptoms might relate to. Suggest a couple of possibilities in a very general way, and strongly emphasize that this is not medical advice and the user should consult a doctor for accurate diagnosis and treatment. Do not provide specific diagnoses or treatments.""" ai_response = gpt(prompt, max_length=250, num_return_sequences=1, do_sample=True)[0]['generated_text'] return f"Based on what you've described, some general health areas to consider could include: {ai_response} It's crucial to remember that I am not a medical professional and this information is for demonstration purposes only. Please consult a qualified doctor for an accurate diagnosis and appropriate management of your health concerns." # Gradio UI interface = gr.Interface( fn=health_chat, inputs=gr.Textbox(lines=2, placeholder="Enter your symptoms, separated by commas, e.g., fever, cough"), outputs=gr.Textbox(placeholder="Possible conditions or AI response will appear here.") ) interface.launch()
80f6c48
verified

Prometheus799 commited on

Update app.py
95b5ceb
verified

Prometheus799 commited on

import gradio as gr from transformers import pipeline # Load a free model from Hugging Face (DistilGPT2) gpt = pipeline("text-generation", model="distilgpt2") # More structured symptoms and conditions database with a basic "likelihood" conditions_db = { "fever": {"flu": 0.8, "cold": 0.7, "malaria": 0.6}, "headache": {"migraine": 0.7, "tension headache": 0.6, "dehydration": 0.5}, "fatigue": {"anemia": 0.7, "thyroid issues": 0.6, "lack of sleep": 0.8}, "cough": {"bronchitis": 0.7, "cold": 0.6, "covid-19": 0.7}, "sore throat": {"strep throat": 0.8, "flu": 0.7, "covid-19": 0.6}, } # Function to predict conditions with likelihood def predict_conditions(symptoms): possible_conditions = {} for symptom in symptoms: symptom = symptom.lower().strip() if symptom in conditions_db: for condition, likelihood in conditions_db[symptom].items(): possible_conditions[condition] = possible_conditions.get(condition, 0) + likelihood # Sort conditions by total likelihood (descending) sorted_conditions = sorted(possible_conditions.items(), key=lambda item: item[1], reverse=True) return [f"{condition} (likelihood: {likelihood:.1f})" for condition, likelihood in sorted_conditions] # Function to respond to user input def health_chat(user_input): if not user_input.strip(): return "Please enter your symptoms." symptoms = [word.strip() for word in user_input.lower().split(",")] predicted_conditions = predict_conditions(symptoms) if predicted_conditions: response = f"Based on the symptoms you described ({', '.join(symptoms)}), possible conditions from our limited database (with a basic likelihood indication) include: {', '.join(predicted_conditions)}. For more specific information and management, please consult a healthcare professional." return response else: prompt = f"""The user is describing some health concerns: "{user_input}". As a helpful AI assistant for demonstration purposes, provide a brief, general overview of potential health areas these symptoms might relate to. Suggest a couple of possibilities in a very general way, and strongly emphasize that this is not medical advice and the user should consult a doctor for accurate diagnosis and treatment. Do not provide specific diagnoses or treatments.""" ai_response = gpt(prompt, max_length=250, num_return_sequences=1, do_sample=True)[0]['generated_text'] return f"Based on what you've described, some general health areas to consider could include: {ai_response} It's crucial to remember that I am not a medical professional and this information is for demonstration purposes only. Please consult a qualified doctor for an accurate diagnosis and appropriate management of your health concerns." # Gradio UI interface = gr.Interface( fn=health_chat, inputs=gr.Textbox(lines=2, placeholder="Enter your symptoms, separated by commas, e.g., fever, cough"), outputs=gr.Textbox(placeholder="Possible conditions or AI response will appear here.") ) interface.launch()
30cb0e3
verified

Prometheus799 commited on

Update app.py
b2f2046
verified

Prometheus799 commited on

Update app.py
1d0ab7d
verified

Prometheus799 commited on

Update app.py
2eebbc3
verified

Prometheus799 commited on

Update requirements.txt
a49e169
verified

Prometheus799 commited on

Update requirements.txt
0e8dcaa
verified

Prometheus799 commited on

Update app.py
e1ec41f
verified

Prometheus799 commited on

import gradio as gr from transformers import pipeline # Load a free model from Hugging Face (DistilGPT2) gpt = pipeline("text-generation", model="distilgpt2") # Sample symptoms and conditions database conditions_db = { "fever": ["flu", "cold", "malaria"], "headache": ["migraine", "tension", "dehydration"], "fatigue": ["anemia", "thyroid issues", "lack of sleep"], "cough": ["bronchitis", "cold", "covid-19"], "sore throat": ["strep throat", "flu", "covid-19"] } # Function to predict conditions def predict_conditions(symptoms): matched_conditions = [] for symptom in symptoms: matched_conditions.extend(conditions_db.get(symptom.lower(), [])) return list(set(matched_conditions)) # Function to respond to user input def health_chat(user_input): symptoms = [word.strip() for word in user_input.lower().split(",")] conditions = predict_conditions(symptoms) if conditions: return f"Based on your symptoms, possible conditions are: {', '.join(conditions)}" else: # fallback to GPT if unknown symptom response = gpt(user_input, max_length=50, do_sample=True)[0]['generated_text'] return response # Gradio UI interface = gr.Interface( fn=health_chat, inputs=gr.Textbox(lines=2, placeholder="Enter your symptoms, e.g. fever, headache"), outputs="text", title="AI Health Assistant", description="Enter your symptoms to get possible conditions or ask general health questions." ) interface.launch()
e7c7e63
verified

Prometheus799 commited on

Update app.py
70a3abb
verified

Prometheus799 commited on

Update app.py
21d65bb
verified

Prometheus799 commited on

Update app.py
b4f4308
verified

Prometheus799 commited on

Update app.py
e41e2c5
verified

Prometheus799 commited on

Update app.py
4654efa
verified

Prometheus799 commited on

Update app.py
ef2a762
verified

Prometheus799 commited on

Update app.py
ae67e71
verified

Prometheus799 commited on

Delete pip
483fd22
verified

Prometheus799 commited on

Update app.py
deeea5a
verified

Prometheus799 commited on

Create pip
053bfeb
verified

Prometheus799 commited on

Update app.py
937ccb6
verified

Prometheus799 commited on

Update app.py
ced299f
verified

Prometheus799 commited on

Update app.py
16373f2
verified

Prometheus799 commited on

Create requirements.txt
ee31b6c
verified

Prometheus799 commited on

Create app.py
22f7f0b
verified

Prometheus799 commited on

initial commit
2a8f5c6
verified

Prometheus799 commited on