Engr-arehmankhan786 commited on
Commit
a02992e
·
verified ·
1 Parent(s): c9c528e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -16
app.py CHANGED
@@ -1,16 +1,25 @@
1
  import streamlit as st
2
  import requests
 
3
 
4
- # App title
5
- st.set_page_config(page_title="MSDS Emergency Chatbot")
6
- st.title("🧯 MSDS Emergency Chatbot")
7
- st.markdown("Ask for emergency safety measures based on chemical hazards.")
8
 
9
- # API config
 
 
 
 
 
 
 
 
 
 
10
  GROQ_API_KEY = st.secrets.get("GROQ_API_KEY") or "your-groq-api-key"
11
- GROQ_MODEL = "llama3-70b-8192" # You may choose another model from Groq if needed
12
 
13
- # Function to query Groq API
14
  def query_groq(prompt):
15
  url = "https://api.groq.com/openai/v1/chat/completions"
16
  headers = {
@@ -20,14 +29,11 @@ def query_groq(prompt):
20
  payload = {
21
  "model": GROQ_MODEL,
22
  "messages": [
23
- {
24
- "role": "system",
25
- "content": (
26
- "You are an emergency safety response assistant. Based on MSDS information, "
27
- "give specific, clear, and concise guidance in emergency situations involving "
28
- "hazardous chemical spills, toxic gas releases, or fires involving flammable substances."
29
- )
30
- },
31
  {"role": "user", "content": prompt}
32
  ],
33
  "temperature": 0.2
@@ -36,7 +42,7 @@ def query_groq(prompt):
36
  response.raise_for_status()
37
  return response.json()["choices"][0]["message"]["content"]
38
 
39
- # Streamlit chat UI
40
  user_input = st.chat_input("Enter your chemical emergency question here...")
41
  if user_input:
42
  st.chat_message("user").write(user_input)
 
1
  import streamlit as st
2
  import requests
3
+ import os
4
 
5
+ # App config
6
+ st.set_page_config(page_title="Chemical Emergency Chatbot", page_icon="☣️")
 
 
7
 
8
+ # Try to load image
9
+ if os.path.exists("1000087676.jpg"):
10
+ st.image("1000087676.jpg", width=200)
11
+ else:
12
+ st.markdown("![Default Image](https://upload.wikimedia.org/wikipedia/commons/thumb/6/63/Hazard_C.svg/1200px-Hazard_C.svg.png)")
13
+
14
+ # Title and subtitle
15
+ st.title("☣️ CHEMICAL EMERGENCY CHATBOT")
16
+ st.markdown("Get rapid guidance for handling hazardous chemical incidents, spills, or toxic releases.")
17
+
18
+ # API Config
19
  GROQ_API_KEY = st.secrets.get("GROQ_API_KEY") or "your-groq-api-key"
20
+ GROQ_MODEL = "llama3-70b-8192"
21
 
22
+ # Groq API Query Function
23
  def query_groq(prompt):
24
  url = "https://api.groq.com/openai/v1/chat/completions"
25
  headers = {
 
29
  payload = {
30
  "model": GROQ_MODEL,
31
  "messages": [
32
+ {"role": "system", "content": (
33
+ "You are an emergency safety response assistant. Based on MSDS information, "
34
+ "give specific, clear, and concise guidance in emergency situations involving "
35
+ "hazardous chemical spills, toxic gas releases, or fires involving flammable substances."
36
+ )},
 
 
 
37
  {"role": "user", "content": prompt}
38
  ],
39
  "temperature": 0.2
 
42
  response.raise_for_status()
43
  return response.json()["choices"][0]["message"]["content"]
44
 
45
+ # Chat input
46
  user_input = st.chat_input("Enter your chemical emergency question here...")
47
  if user_input:
48
  st.chat_message("user").write(user_input)