|
|
|
import streamlit as st |
|
import requests |
|
from geopy.geocoders import Nominatim |
|
|
|
|
|
API_URL = "https://api-inference.huggingface.co/models/dmis-lab/biobert-base-cased-v1.1" |
|
headers = {"Authorization": ""} |
|
|
|
|
|
def query(payload): |
|
response = requests.post(API_URL, headers=headers, json=payload) |
|
if response.status_code == 200: |
|
return response.json() |
|
else: |
|
st.error("Error: Unable to fetch response from model") |
|
st.error(response.text) |
|
return None |
|
|
|
|
|
def find_nearby_clinics(address): |
|
geolocator = Nominatim(user_agent="healthcare_companion") |
|
location = geolocator.geocode(address) |
|
if location: |
|
return (location.latitude, location.longitude) |
|
else: |
|
st.error("Error: Address not found") |
|
return None |
|
|
|
|
|
def main(): |
|
st.title("Healthcare Companion") |
|
st.write("This app provides healthcare guidance, prescription information, and locates nearby clinics or pharmacies.") |
|
|
|
|
|
symptoms = st.text_area("Enter your symptoms (e.g., 'I am having a cough, weak knee, swollen eyes'):") |
|
if symptoms: |
|
context = """ |
|
This is a healthcare question and answer platform. The following text contains typical symptoms, treatments, and medical conditions commonly asked about in healthcare settings. |
|
For example, symptoms of COVID-19 include fever, dry cough, and tiredness. Treatment options for hypertension include lifestyle changes and medications. The platform is designed to assist with general medical inquiries. |
|
""" |
|
payload = {"inputs": {"question": symptoms, "context": context}} |
|
st.write(f"Debug: Payload sent to model: {payload}") |
|
result = query(payload) |
|
st.write(f"Debug: Response from model: {result}") |
|
if result: |
|
st.write("**Medical Advice:**") |
|
st.write(result.get('answer', "Sorry, I don't have information on that.")) |
|
|
|
|
|
address = st.text_input("Enter your address to find nearby clinics/pharmacies:") |
|
if address: |
|
location = find_nearby_clinics(address) |
|
if location: |
|
st.write(f"**Nearby Clinics/Pharmacies (Coordinates):** {location}") |
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
main() |
|
|