import streamlit as st import os from groq import Groq # Set up Groq API os.environ['GROQ_API_KEY'] = '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' client = Groq(api_key=os.environ.get("GROQ_API_KEY")) # Function to get Medbot's response def medbot_response(user_input): try: chat_completion = client.chat.completions.create( messages=[ {"role": "system", "content": ( "You are Medbot, a highly intelligent personal healthcare assistant and doctor. " "You provide accurate diagnoses based on symptoms and detailed medical information. " "Be polite, informative, and user-friendly." )}, {"role": "user", "content": user_input} ], model="llama-3.3-70b-versatile", ) return chat_completion.choices[0].message.content except Exception as e: return f"Error: {str(e)}" # Streamlit App st.set_page_config(page_title="Medbot", page_icon="🩺", layout="centered") # App Title st.markdown("

Medbot 🩺

", unsafe_allow_html=True) st.markdown("

Your Personal Healthcare Assistant

", unsafe_allow_html=True) # Sidebar with green hearts and options st.sidebar.markdown("

Hello! I'm Medbot! 💚

", unsafe_allow_html=True) st.sidebar.write("I can help you with: ") st.sidebar.markdown(""" """, unsafe_allow_html=True) # Chat Interface st.markdown("
", unsafe_allow_html=True) user_input = st.text_input("Enter your symptoms or question:", "") if st.button("Submit"): if user_input: response = medbot_response(user_input) # Display Medbot's response in styled chat bubble st.markdown( f"
" f"

Medbot: {response}

", unsafe_allow_html=True ) else: st.warning("Please enter a message to proceed.") # Footer st.markdown( "", unsafe_allow_html=True )