Arshad112 commited on
Commit
abeb042
·
verified ·
1 Parent(s): a7eb759

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from groq import Groq
4
+
5
+ # Load the API key from the environment
6
+ api_key = os.getenv("GROQ_API_KEY")
7
+ client = Groq(api_key=api_key)
8
+
9
+ # Function to call the Groq API and get the chatbot response
10
+ def get_chat_response(query):
11
+ chat_completion = client.chat.completions.create(
12
+ messages=[{"role": "user", "content": query}],
13
+ model="llama-3.3-70b-versatile",
14
+ )
15
+ return chat_completion.choices[0].message.content
16
+
17
+ # Streamlit app interface
18
+ def main():
19
+ st.title("Health Assistant Chatbot")
20
+
21
+ # Provide health-related options for users
22
+ st.write("Please ask a health-related question. The chatbot can answer questions about fever, flu, cough, malaria, and typhoid symptoms.")
23
+
24
+ # Input from the user
25
+ user_input = st.text_input("Ask a health-related question:")
26
+
27
+ if user_input:
28
+ # Check if the question is health-related
29
+ health_keywords = ["fever", "flu", "cough", "malaria", "typhoid"]
30
+ if any(keyword in user_input.lower() for keyword in health_keywords):
31
+ response = get_chat_response(user_input)
32
+ st.write("Chatbot Response:", response)
33
+ else:
34
+ st.write("Sorry, I do not have knowledge of this topic. Please ask only health-related questions.")
35
+
36
+ if __name__ == "__main__":
37
+ main()