abdullahzunorain
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -45,18 +45,13 @@ 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 and
|
54 |
-
|
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(
|
@@ -72,7 +67,7 @@ def get_outfit_suggestion(temperature, description, style, fabric, weather_categ
|
|
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);
|
@@ -120,10 +115,15 @@ st.title("🌤️ Weather-Based Outfit Suggestion App")
|
|
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 |
-
#
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
127 |
fabric = st.selectbox("Select your preferred fabric", ["Cotton", "Linen", "Wool", "Polyester", "Silk", "Leather"])
|
128 |
|
129 |
if city:
|
@@ -139,8 +139,8 @@ if city:
|
|
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
|
143 |
-
outfit_suggestion, weather_icon = get_outfit_suggestion(temperature, description, style, fabric, weather_category, weather_icon
|
144 |
|
145 |
if outfit_suggestion:
|
146 |
# Display outfit suggestion
|
@@ -181,6 +181,8 @@ st.markdown(
|
|
181 |
|
182 |
|
183 |
|
|
|
|
|
184 |
# import requests
|
185 |
# import streamlit as st
|
186 |
# 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):
|
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 custom style
|
54 |
+
prompt = f"The current weather is {description} with a temperature of {temperature}°C. The weather category is {weather_category}. Suggest an outfit. The user prefers a {style} style and {fabric} fabric."
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
# Use Groq's chat completion to get the text response
|
57 |
response = client.chat.completions.create(
|
|
|
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);
|
|
|
115 |
city = st.text_input("Enter your location:", placeholder="E.g. Peshawar")
|
116 |
|
117 |
# Gender selection
|
118 |
+
gender = st.selectbox("Select your gender", ["Male", "Female", "Other"])
|
119 |
|
120 |
+
# Custom style input
|
121 |
+
custom_style = st.text_input("Enter your personalized style (optional)", placeholder="E.g. Vintage, Sporty")
|
122 |
+
|
123 |
+
# If no custom style is provided, default to the selected style
|
124 |
+
style = custom_style if custom_style else st.selectbox("Select your preferred style", ["Casual", "Formal", "Sporty", "Business", "Chic"])
|
125 |
+
|
126 |
+
# Fabric preference
|
127 |
fabric = st.selectbox("Select your preferred fabric", ["Cotton", "Linen", "Wool", "Polyester", "Silk", "Leather"])
|
128 |
|
129 |
if city:
|
|
|
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
|
143 |
+
outfit_suggestion, weather_icon = get_outfit_suggestion(temperature, description, style, fabric, weather_category, weather_icon)
|
144 |
|
145 |
if outfit_suggestion:
|
146 |
# Display outfit suggestion
|
|
|
181 |
|
182 |
|
183 |
|
184 |
+
|
185 |
+
|
186 |
# import requests
|
187 |
# import streamlit as st
|
188 |
# import groq
|