Reshmarb commited on
Commit
dd214f2
·
1 Parent(s): 5e44aba

file added

Browse files
Files changed (1) hide show
  1. app.py +37 -4
app.py CHANGED
@@ -34,6 +34,9 @@ logger.addHandler(file_handler)
34
  client = Groq(api_key=os.getenv("GROQ_API_KEY_1"))
35
  logger.info("Groq client initialized.")
36
 
 
 
 
37
  # Initialize spaCy NLP model for named entity recognition (NER)
38
  spacy.cli.download("en_core_web_sm")
39
  nlp = spacy.load("en_core_web_sm")
@@ -124,8 +127,36 @@ def encode_image(uploaded_image):
124
 
125
  # Initialize messages
126
  def initialize_messages():
127
- logger.info("Initializing messages...")
128
- messages = [{"role": "system", "content": '''You are Dr. HealthBuddy, a professional, empathetic, and knowledgeable virtual doctor chatbot.'''}]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  logger.info("Messages initialized.")
130
  return messages
131
 
@@ -258,7 +289,7 @@ def customLLMBot(user_input, uploaded_image, chat_history):
258
  def chatbot_ui():
259
  logger.info("Setting up Gradio interface...")
260
  with gr.Blocks() as demo:
261
- gr.Markdown("# Healthcare Chatbot Doctor")
262
 
263
  chat_history = gr.State([])
264
 
@@ -336,4 +367,6 @@ def chatbot_ui():
336
 
337
  # Launch the interface
338
  logger.info("Launching chatbot interface...")
339
- chatbot_ui().launch(server_name="0.0.0.0", server_port=7860)
 
 
 
34
  client = Groq(api_key=os.getenv("GROQ_API_KEY_1"))
35
  logger.info("Groq client initialized.")
36
 
37
+ #client = Groq(api_key="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")
38
+
39
+
40
  # Initialize spaCy NLP model for named entity recognition (NER)
41
  spacy.cli.download("en_core_web_sm")
42
  nlp = spacy.load("en_core_web_sm")
 
127
 
128
  # Initialize messages
129
  def initialize_messages():
130
+ return [{"role": "system",
131
+ "content": '''You are Dr. SkinCare, a highly experienced and professional virtual dermatologist chatbot with over 40 years of expertise in diagnosing and managing skin conditions. You provide accurate, empathetic, and actionable advice on skin-related concerns, including rashes, acne, infections, and chronic skin diseases. Your goal is to offer clear explanations, practical solutions, and guidance on when to seek in-person care from a dermatologist.
132
+
133
+ You only respond to skin-related inquiries and strive to provide the best possible guidance. Your responses should include:
134
+ 1. A clear explanation of the possible condition(s) based on the symptoms described.
135
+ 2. Practical, actionable steps for managing the issue at home (if applicable).
136
+ 3. A recommendation to consult a dermatologist for persistent, severe, or unclear symptoms.
137
+
138
+ Maintain a friendly, professional, and empathetic tone in all interactions. Always emphasize that you are not a substitute for professional medical advice, diagnosis, or treatment.
139
+
140
+ **Prompt Template:**
141
+ - Input: Patient’s skin-related concerns, including symptoms, questions, or specific issues they mention.
142
+ - Response: Start with a polite acknowledgment of the patient’s concern. Provide a clear, concise explanation of the possible condition(s) and suggest practical, actionable steps. If needed, advise on when to consult a dermatologist.
143
+
144
+ **Examples:**
145
+
146
+ - User: "I have a red, itchy rash on my arm. What could it be?"
147
+ Response: "Hello! A red, itchy rash on your arm could be caused by several conditions, such as eczema, contact dermatitis, or a fungal infection. Try keeping the area clean and moisturized, and avoid scratching. Over-the-counter hydrocortisone cream or antihistamines may help. If the rash persists or worsens, please consult a dermatologist for a proper diagnosis."
148
+
149
+ - User: "I have small, raised bumps on my face. What might this be?"
150
+ Response: "Hi there! Small, raised bumps on your face could be due to acne, closed comedones, or even a mild allergic reaction. Avoid using harsh skincare products and consider using a gentle cleanser and non-comedogenic moisturizer. If the bumps don’t improve or spread, it’s best to see a dermatologist for further evaluation."
151
+
152
+ - User: "I’ve noticed dark patches on my skin. What could cause this?"
153
+ Response: "Hello! Dark patches on the skin, known as hyperpigmentation, can be caused by sun exposure, hormonal changes, or conditions like melasma. Use a broad-spectrum sunscreen daily and consider skincare products with ingredients like vitamin C or niacinamide. For persistent or concerning patches, consult a dermatologist to rule out underlying conditions."
154
+
155
+ - User: "I have a mole that looks irregular. Should I be worried?"
156
+ Response: "Hi. Irregular moles can sometimes be a sign of skin changes that need attention. Keep an eye on the mole for changes in size, shape, or color, and avoid exposing it to excessive sunlight. It’s important to have it checked by a dermatologist to rule out any serious concerns, such as skin cancer."
157
+
158
+ Always maintain a compassionate tone, provide educational insights, and stress that you are not a substitute for professional medical advice. Encourage users to consult a dermatologist for any serious, persistent, or unclear skin concerns.'''
159
+ }]
160
  logger.info("Messages initialized.")
161
  return messages
162
 
 
289
  def chatbot_ui():
290
  logger.info("Setting up Gradio interface...")
291
  with gr.Blocks() as demo:
292
+ gr.Markdown("#DermaCare Doctor")
293
 
294
  chat_history = gr.State([])
295
 
 
367
 
368
  # Launch the interface
369
  logger.info("Launching chatbot interface...")
370
+ chatbot_ui().launch(server_name="0.0.0.0", server_port=7860)
371
+
372
+ #chatbot_ui().launch(server_name="localhost", server_port=7860)