| | import os |
| | import streamlit as st |
| | from groq import Groq |
| | from dotenv import load_dotenv |
| |
|
| | |
| | load_dotenv() |
| |
|
| | |
| | api_key = os.getenv("GROQ_API_KEY") |
| |
|
| | |
| | if not api_key: |
| | st.error("API key not found. Please make sure the GROQ_API_KEY is set in your .env file.") |
| | else: |
| | client = Groq(api_key=api_key) |
| |
|
| | |
| | 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 |
| |
|
| | |
| | def main(): |
| | st.title("Health Assistant Chatbot") |
| |
|
| | |
| | st.write("Please ask a health-related question. The chatbot can answer questions about fever, flu, cough, malaria, and typhoid symptoms.") |
| |
|
| | |
| | user_input = st.text_input("Ask a health-related question:") |
| |
|
| | if user_input: |
| | |
| | health_keywords = ["fever", "flu", "cough", "malaria", "typhoid"] |
| | 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 do not have knowledge of this topic. Please ask only health-related questions.") |
| |
|
| | if __name__ == "__main__": |
| | main() |
| |
|