File size: 1,962 Bytes
e901ffa
 
 
 
 
 
 
 
 
2a29d26
e901ffa
2a29d26
e901ffa
 
 
2a29d26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import streamlit as st
from groq import Groq
from dotenv import load_dotenv

# Load environment variables
load_dotenv()
api_key = os.getenv("GROQ_API_KEY")

# Ensure API key is available
if not api_key:
    st.error("API key not found. Please set GROQ_API_KEY in the .env file.")
    st.stop()

# Initialize Groq client
client = Groq(api_key=api_key)

# Function to get chatbot response
def get_chat_response(query):
    chat_completion = client.chat.completions.create(
        messages=[{"role": "user", "content": query}],
        model="llama-3.3-70b-versatile",
    )
    return chat_completion.choices[0].message.content

# Streamlit app interface
def main():
    st.title("Health Assistant Chatbot")
    st.write("Ask about health issues and get proper treatment suggestions.")
    
    user_input = st.text_input("Enter your health-related question:")

    if user_input:
        health_keywords = [
            "fever", "flu", "cough", "malaria", "typhoid", "asthma", "diabetes", "hypertension", "migraine", 
            "pneumonia", "dengue", "tuberculosis", "arthritis", "chickenpox", "measles", "bronchitis", "anemia", 
            "jaundice", "ulcer", "gastritis", "depression", "anxiety", "stroke", "eczema", "psoriasis", "obesity", 
            "cholera", "hepatitis", "insomnia", "thyroid", "sinusitis", "tonsillitis", "vertigo", "osteoporosis", 
            "conjunctivitis", "paralysis", "malnutrition", "appendicitis", "epilepsy", "gallstones", "gout", 
            "kidney stones", "meningitis", "mumps", "pancreatitis", "pneumothorax", "scabies", "scoliosis", "sepsis", 
            "syphilis", "tetanus"
        ]
        
        if any(keyword in user_input.lower() for keyword in health_keywords):
            response = get_chat_response(user_input)
            st.write("Chatbot Response:", response)
        else:
            st.write("Sorry, I only answer health-related questions.")

if __name__ == "__main__":
    main()