abdullahzunorain
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -45,14 +45,19 @@ def categorize_weather(description):
|
|
45 |
return "Uncategorized", "🔍"
|
46 |
|
47 |
# Function to get outfit suggestion using Groq's LLaMA model
|
48 |
-
def get_outfit_suggestion(temperature, description, style, fabric, weather_category, weather_icon):
|
49 |
# Initialize Groq's API
|
50 |
try:
|
51 |
client = groq.Groq(api_key=groq_api_key) # Use the secret API key
|
52 |
|
53 |
-
# Adjust the prompt based on the weather category
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
56 |
# Use Groq's chat completion to get the text response
|
57 |
response = client.chat.completions.create(
|
58 |
messages=[{"role": "user", "content": prompt}],
|
@@ -67,7 +72,7 @@ def get_outfit_suggestion(temperature, description, style, fabric, weather_categ
|
|
67 |
st.set_page_config(page_title="Weather-Based Outfit Suggestion", page_icon="🌤️", layout="wide")
|
68 |
|
69 |
# Custom styles
|
70 |
-
st.markdown("""
|
71 |
<style>
|
72 |
.reportview-container {
|
73 |
background: linear-gradient(135deg, #ffcc00, #ff7b00);
|
@@ -114,6 +119,9 @@ st.title("🌤️ Weather-Based Outfit Suggestion App")
|
|
114 |
# User input
|
115 |
city = st.text_input("Enter your location:", placeholder="E.g. Peshawar")
|
116 |
|
|
|
|
|
|
|
117 |
# Style and fabric preferences
|
118 |
style = st.selectbox("Select your preferred style", ["Casual", "Formal", "Sporty", "Business", "Chic"])
|
119 |
fabric = st.selectbox("Select your preferred fabric", ["Cotton", "Linen", "Wool", "Polyester", "Silk", "Leather"])
|
@@ -131,8 +139,8 @@ if city:
|
|
131 |
st.write(f"Weather: {description} {weather_icon}")
|
132 |
st.write(f"Weather Category: {weather_category} {weather_icon}")
|
133 |
|
134 |
-
# Get outfit suggestion based on user preferences
|
135 |
-
outfit_suggestion, weather_icon = get_outfit_suggestion(temperature, description, style, fabric, weather_category, weather_icon)
|
136 |
|
137 |
if outfit_suggestion:
|
138 |
# Display outfit suggestion
|
@@ -171,6 +179,8 @@ st.markdown(
|
|
171 |
|
172 |
|
173 |
|
|
|
|
|
174 |
# import requests
|
175 |
# import streamlit as st
|
176 |
# import groq
|
|
|
45 |
return "Uncategorized", "🔍"
|
46 |
|
47 |
# Function to get outfit suggestion using Groq's LLaMA model
|
48 |
+
def get_outfit_suggestion(temperature, description, style, fabric, weather_category, weather_icon, gender):
|
49 |
# Initialize Groq's API
|
50 |
try:
|
51 |
client = groq.Groq(api_key=groq_api_key) # Use the secret API key
|
52 |
|
53 |
+
# Adjust the prompt based on the weather category and gender
|
54 |
+
if gender == "Male":
|
55 |
+
prompt = f"The current weather is {description} with a temperature of {temperature}°C. The weather category is {weather_category}. Suggest a stylish outfit for a man who prefers a {style} style and {fabric} fabric."
|
56 |
+
elif gender == "Female":
|
57 |
+
prompt = f"The current weather is {description} with a temperature of {temperature}°C. The weather category is {weather_category}. Suggest a stylish outfit for a woman who prefers a {style} style and {fabric} fabric."
|
58 |
+
else:
|
59 |
+
prompt = f"The current weather is {description} with a temperature of {temperature}°C. The weather category is {weather_category}. Suggest a stylish outfit for someone who prefers a {style} style and {fabric} fabric."
|
60 |
+
|
61 |
# Use Groq's chat completion to get the text response
|
62 |
response = client.chat.completions.create(
|
63 |
messages=[{"role": "user", "content": prompt}],
|
|
|
72 |
st.set_page_config(page_title="Weather-Based Outfit Suggestion", page_icon="🌤️", layout="wide")
|
73 |
|
74 |
# Custom styles
|
75 |
+
st.markdown("""
|
76 |
<style>
|
77 |
.reportview-container {
|
78 |
background: linear-gradient(135deg, #ffcc00, #ff7b00);
|
|
|
119 |
# User input
|
120 |
city = st.text_input("Enter your location:", placeholder="E.g. Peshawar")
|
121 |
|
122 |
+
# Gender selection
|
123 |
+
gender = st.selectbox("Select your gender", ["Male", "Female"])
|
124 |
+
|
125 |
# Style and fabric preferences
|
126 |
style = st.selectbox("Select your preferred style", ["Casual", "Formal", "Sporty", "Business", "Chic"])
|
127 |
fabric = st.selectbox("Select your preferred fabric", ["Cotton", "Linen", "Wool", "Polyester", "Silk", "Leather"])
|
|
|
139 |
st.write(f"Weather: {description} {weather_icon}")
|
140 |
st.write(f"Weather Category: {weather_category} {weather_icon}")
|
141 |
|
142 |
+
# Get outfit suggestion based on user preferences and gender
|
143 |
+
outfit_suggestion, weather_icon = get_outfit_suggestion(temperature, description, style, fabric, weather_category, weather_icon, gender)
|
144 |
|
145 |
if outfit_suggestion:
|
146 |
# Display outfit suggestion
|
|
|
179 |
|
180 |
|
181 |
|
182 |
+
|
183 |
+
|
184 |
# import requests
|
185 |
# import streamlit as st
|
186 |
# import groq
|