File size: 1,600 Bytes
2438a4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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**")