makeup_chat_bot / app.py
snehakingrani's picture
Create app.py
2438a4c verified
import streamlit as st
from groq import Groq
import os
from dotenv import load_dotenv
# Load API key from .env file
load_dotenv()
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
# Ensure API key is set
if not GROQ_API_KEY:
st.error("API key is missing. Please check your .env file.")
st.stop()
# Initialize Groq API Client with API Key
client = Groq(api_key=GROQ_API_KEY)
# Streamlit UI
st.set_page_config(page_title="πŸ’„ Makeup & Cosmetics Assistant", layout="wide")
st.title("πŸ’„ Makeup & Cosmetics Assistant")
st.write("Ask anything about makeup brands, beauty tips, and skincare!")
# User input
user_query = st.text_input("Enter your question:", "")
if st.button("Ask"):
if user_query.strip():
with st.spinner("Fetching response..."):
# Query the DeepSeek model
completion = client.chat.completions.create(
model="deepseek-r1-distill-qwen-32b",
messages=[{"role": "user", "content": user_query}],
temperature=0.6,
max_completion_tokens=4096,
top_p=0.95,
stream=True,
stop=None,
)
# Display response
response_text = ""
for chunk in completion:
response_text += chunk.choices[0].delta.content or ""
st.write("**πŸ’‘ Answer:**")
st.write(response_text)
else:
st.warning("Please enter a valid question related to makeup and cosmetics!")
# Footer
st.markdown("---")
st.markdown("πŸ”Ή **Powered by DeepSeek-R1-Distill-Qwen-32B & Groq API**")