Spaces:
Sleeping
Sleeping
Update app.py
#1
by
Engr-arehmankhan786
- opened
app.py
CHANGED
@@ -1,16 +1,21 @@
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
|
4 |
-
# App
|
5 |
-
st.set_page_config(page_title="
|
6 |
-
st.title("🧯 MSDS Emergency Chatbot")
|
7 |
-
st.markdown("Ask for emergency safety measures based on chemical hazards.")
|
8 |
|
9 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
GROQ_API_KEY = st.secrets.get("GROQ_API_KEY") or "your-groq-api-key"
|
11 |
-
GROQ_MODEL = "llama3-70b-8192"
|
12 |
|
13 |
-
# Function to
|
14 |
def query_groq(prompt):
|
15 |
url = "https://api.groq.com/openai/v1/chat/completions"
|
16 |
headers = {
|
@@ -36,10 +41,10 @@ def query_groq(prompt):
|
|
36 |
response.raise_for_status()
|
37 |
return response.json()["choices"][0]["message"]["content"]
|
38 |
|
39 |
-
#
|
40 |
user_input = st.chat_input("Enter your chemical emergency question here...")
|
41 |
if user_input:
|
42 |
st.chat_message("user").write(user_input)
|
43 |
with st.spinner("Getting emergency response information..."):
|
44 |
reply = query_groq(user_input)
|
45 |
-
st.chat_message("assistant").write(reply)
|
|
|
1 |
import streamlit as st
|
2 |
import requests
|
3 |
|
4 |
+
# App configuration
|
5 |
+
st.set_page_config(page_title="Chemical Emergency Chatbot", page_icon="☣️")
|
|
|
|
|
6 |
|
7 |
+
# Display logo (make sure 1000087676.jpg is in the same folder)
|
8 |
+
st.image("1000087676.jpg", width=200)
|
9 |
+
|
10 |
+
# Title and subtitle
|
11 |
+
st.title("☣️ CHEMICAL EMERGENCY CHATBOT")
|
12 |
+
st.markdown("Get rapid guidance for handling hazardous chemical incidents, spills, or toxic releases.")
|
13 |
+
|
14 |
+
# API Configuration
|
15 |
GROQ_API_KEY = st.secrets.get("GROQ_API_KEY") or "your-groq-api-key"
|
16 |
+
GROQ_MODEL = "llama3-70b-8192"
|
17 |
|
18 |
+
# Function to call Groq API
|
19 |
def query_groq(prompt):
|
20 |
url = "https://api.groq.com/openai/v1/chat/completions"
|
21 |
headers = {
|
|
|
41 |
response.raise_for_status()
|
42 |
return response.json()["choices"][0]["message"]["content"]
|
43 |
|
44 |
+
# Chat UI
|
45 |
user_input = st.chat_input("Enter your chemical emergency question here...")
|
46 |
if user_input:
|
47 |
st.chat_message("user").write(user_input)
|
48 |
with st.spinner("Getting emergency response information..."):
|
49 |
reply = query_groq(user_input)
|
50 |
+
st.chat_message("assistant").write(reply)
|