import streamlit as st import requests # App configuration st.set_page_config(page_title="Chemical Emergency Chatbot", page_icon="☣️") # Display logo (make sure 1000087676.jpg is in the same folder) st.image("1000087676.jpg", width=200) # Title and subtitle st.title("☣️ CHEMICAL EMERGENCY CHATBOT") st.markdown("Get rapid guidance for handling hazardous chemical incidents, spills, or toxic releases.") # API Configuration GROQ_API_KEY = st.secrets.get("GROQ_API_KEY") or "your-groq-api-key" GROQ_MODEL = "llama3-70b-8192" # Function to call Groq API def query_groq(prompt): url = "https://api.groq.com/openai/v1/chat/completions" headers = { "Authorization": f"Bearer {GROQ_API_KEY}", "Content-Type": "application/json" } payload = { "model": GROQ_MODEL, "messages": [ { "role": "system", "content": ( "You are an emergency safety response assistant. Based on MSDS information, " "give specific, clear, and concise guidance in emergency situations involving " "hazardous chemical spills, toxic gas releases, or fires involving flammable substances." ) }, {"role": "user", "content": prompt} ], "temperature": 0.2 } response = requests.post(url, headers=headers, json=payload) response.raise_for_status() return response.json()["choices"][0]["message"]["content"] # Chat UI user_input = st.chat_input("Enter your chemical emergency question here...") if user_input: st.chat_message("user").write(user_input) with st.spinner("Getting emergency response information..."): reply = query_groq(user_input) st.chat_message("assistant").write(reply)