Spaces:
Sleeping
Sleeping
File size: 2,551 Bytes
73ec8df 6c43050 73ec8df 1b16f02 b7ec746 1b16f02 b7ec746 1b16f02 b7ec746 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
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("<h1 style='text-align: center; color: #4CAF50;'>Medbot π©Ί</h1>", unsafe_allow_html=True)
st.markdown("<h3 style='text-align: center;'>Your Personal Healthcare Assistant</h3>", unsafe_allow_html=True)
# Sidebar with green hearts and options
st.sidebar.markdown("<h3 style='color: #4CAF50;'>Hello! I'm Medbot! π</h3>", unsafe_allow_html=True)
st.sidebar.write("I can help you with: ")
st.sidebar.markdown("""
<ul style='color: #4CAF50; font-size: 16px;'>
<li>π <strong>Symptom Analysis</strong></li>
<li>π <strong>Medical Condition Information</strong></li>
<li>π <strong>Health Tips</strong></li>
</ul>
""", unsafe_allow_html=True)
# Chat Interface
st.markdown("<hr style='border:1px solid #D3D3D3'>", 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"<div style='background-color: #f0f8e8; border-radius: 10px; padding: 10px;'>"
f"<p style='color: #006400; font-size: 16px;'><strong>Medbot:</strong> {response}</p></div>",
unsafe_allow_html=True
)
else:
st.warning("Please enter a message to proceed.")
# Footer
st.markdown(
"<footer style='text-align: center; color: #888;'>"
"Built with β€οΈ using Streamlit & Groq AI</footer>",
unsafe_allow_html=True
)
|