import streamlit as st import requests from geopy.geocoders import Nominatim # Set your Hugging Face API URL and API key API_URL = "https://api-inference.huggingface.co/models/dmis-lab/biobert-base-cased-v1.1" headers = {"Authorization": "Bearer YOUR_HUGGING_FACE_API_KEY"} # Function to query the Hugging Face model 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 # Function to find nearby clinics/pharmacies using geopy 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 # Main function to create the Streamlit app def main(): st.title("Healthcare Companion") st.write("This app provides healthcare guidance, prescription information, and locates nearby clinics or pharmacies.") # User input for medical symptoms 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}") # Debugging: Check payload result = query(payload) st.write(f"Debug: Response from model: {result}") # Debugging: Check response if result: st.write("**Medical Advice:**") st.write(result.get('answer', "Sorry, I don't have information on that.")) # User input for address to find nearby clinics/pharmacies 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}") # Additional features like prescription info can be added similarly if __name__ == "__main__": main()