alessiodevoto commited on
Commit
d87742b
1 Parent(s): 549e367

update template

Browse files
Files changed (3) hide show
  1. app.py +2 -1
  2. newsletter_examples/1.html +142 -158
  3. src/utils_api.py +2 -0
app.py CHANGED
@@ -175,7 +175,8 @@ def main():
175
  newsletter_output = gr.HTML(
176
  label="Generated Newsletter",
177
  value="<br><br><br><br><br>",
178
- min_height=500
 
179
  )
180
 
181
  # Event Binding
 
175
  newsletter_output = gr.HTML(
176
  label="Generated Newsletter",
177
  value="<br><br><br><br><br>",
178
+ min_height=500,
179
+ render=True
180
  )
181
 
182
  # Event Binding
newsletter_examples/1.html CHANGED
@@ -1,167 +1,151 @@
1
  <!DOCTYPE html>
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Your Personalized Style Curation</title>
7
- <style>
8
- /* Elegant, sophisticated color palette with light brown background */
9
- body {
10
- margin: 0;
11
- padding: 0;
12
- width: 100%;
13
- font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
14
- line-height: 1.6;
15
- color: #4A4A4A;
16
- background-color: #F0E6D2; /* Light warm brown background */
17
- }
18
-
19
- .backgroundcontainer {
20
- max-width: 600px;
21
- margin: 0 auto;
22
- padding: 30px;
23
- background-color: #f5f0e6;
24
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
25
- border: 1px solid #E0D3BA; /* Slight border to complement background */
26
- }
27
-
28
- .header {
29
- text-align: center;
30
- padding: 20px 0;
31
- border-bottom: 1px solid #D4AD7A;
32
- margin-bottom: 30px;
33
- }
34
-
35
- .header img {
36
- max-width: 200px;
37
- height: auto;
38
- }
39
-
40
- .section {
41
- margin-bottom: 40px;
42
- }
43
-
44
- h1, h2, h3 {
45
- font-family: 'Didot', serif;
46
- color: #5D4037; /* Deep brown for headings */
47
- margin-bottom: 15px;
48
- }
49
-
50
- /* New responsive section styles */
51
- .section-row {
52
- display: flex;
53
- flex-wrap: wrap;
54
- justify-content: space-between;
55
- gap: 20px;
56
- }
57
-
58
- .bought-item, .product {
59
- display: flex;
60
- flex-direction: column;
61
- align-items: center;
62
- width: calc(50% - 10px); /* Adjust for gap */
63
- margin: 10px 0;
64
- text-align: center;
65
- padding: 20px;
66
- background-color: #FFF8E7;
67
- border-radius: 8px;
68
- border: 1px solid #E0D3BA;
69
- transition: transform 0.3s ease;
70
- }
71
-
72
- /* Media query for smaller screens */
73
- @media screen and (max-width: 600px) {
74
- .section-row {
75
- flex-direction: column;
76
  }
77
 
78
  .bought-item, .product {
79
- width: 100%;
 
 
 
80
  margin: 10px 0;
 
 
 
 
 
 
81
  }
82
- }
83
-
84
- .bought-item:hover, .product:hover {
85
- transform: scale(1.02);
86
- box-shadow: 0 4px 6px rgba(0,0,0,0.1);
87
- }
88
-
89
- .deal-box {
90
- background-color: #F5E6D3; /* Soft light brown */
91
- color: black; /* This will make the text black */
92
- padding: 20px;
93
- margin: 15px 0;
94
- border-radius: 8px;
95
- text-align: center;
96
- border: 1px solid #D4AD7A;
97
- }
98
-
99
- .button {
100
- display: inline-block;
101
- padding: 12px 25px;
102
- background-color: #8B6914; /* Rich brown */
103
- color: #FFFFFF !important; /* Explicitly enforce white */
104
- text-decoration: none;
105
- border-radius: 5px;
106
- font-weight: 600;
107
- text-transform: uppercase;
108
- letter-spacing: 1px;
109
- transition: background-color 0.3s ease;
110
- }
111
-
112
- .button:link,
113
- .button:visited,
114
- .button:hover,
115
- .button:active {
116
- color: #FFFFFF; /* Ensure white for all link states */
117
- text-decoration: none;
118
- }
119
-
120
- .button:hover {
121
- background-color: #5D4037; /* Darker brown */
122
- }
123
-
124
- .footer {
125
- text-align: center;
126
- padding: 20px;
127
- background-color: #F5E6D3; /* Soft light brown */
128
- border-top: 1px solid #D4AD7A;
129
- font-size: 0.9em;
130
- }
131
-
132
- .price {
133
- font-size: 1.2em;
134
- color: #8B6914; /* Rich brown */
135
- font-weight: bold;
136
- }
137
-
138
- a {
139
- color: #8B6914; /* Rich brown */
140
- text-decoration: none;
141
- }
142
-
143
- a:hover {
144
- text-decoration: underline;
145
- }
146
- </style>
147
- </head>
148
  <body>
149
- <div class="backgroundcontainer">
150
- <!-- Header Section -->
151
- <div class="header" style="display: flex; justify-content: center; align-items: center;">
152
  <img src="${brand_logo}" alt="Brand Logo">
153
  </div>
154
 
155
  <!-- Personal Greeting -->
156
- <div class="section">
157
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; line-height: 1.5; color: #333; letter-spacing: 0.5px; text-align: left;">
158
  ${greeting} </p>
159
  </div>
160
 
161
- <!-- Previously Bought Items Section -->
162
- <div class="section">
163
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; color: #333; line-height: 1.5; letter-spacing: 0.5px; text-align: left;"> ${intro} </p>
164
- <div class="section-row">
165
  <div class="bought-item">
166
  <img src= ${transaction_url} alt="Previous Product 1">
167
  <h3> ${transaction_name} </h3>
@@ -176,23 +160,23 @@ ${greeting} </p>
176
  <!-- Recommended Items -->
177
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; color: #333; line-height: 1.5; letter-spacing: 0.5px; text-align: left;">
178
  ${recommendations} </p>
179
- <div class="section">
180
- <div class="section-row">
181
  <div class="product">
182
  <img src=${recommendation_url} alt="Recommended Product 1">
183
  <h3>${recommendation_name}</h3>
184
- <a href="#" class="button" >Explore</a>
185
  </div>
186
  <div class="product">
187
  <img src=${recommendation_url} alt="Recommended Product 2">
188
  <h3>${recommendation_name}</h3>
189
- <a href="#" class="button">Explore</a>
190
  </div>
191
  </div>
192
  </div>
193
 
194
- <!-- Deals Section -->
195
- <div class="section">
196
  <h2 style="color: #8B6914;">Not Your Style?</h2>
197
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; color: #333; line-height: 1.5; letter-spacing: 0.5px; text-align: left;">
198
  Well, I always try my best and recommend what I think would suit you well, but hey, we all make mistakes, right? </p>
@@ -211,14 +195,14 @@ ${closing} </p>
211
  </div>
212
 
213
  <!-- Call to Action -->
214
- <div class="section" style="text-align: center;">
215
  <h2>Ready to Refine Your Wardrobe?</h2>
216
- <a href="#" class="button">View New Arrivals</a>
217
- <a href="#" class="button" style="background-color: #5D4037;">Book Styling Consultation</a>
218
  </div>
219
 
220
- <!-- Footer -->
221
- <div class="footer">
222
  <p style="font-weight: bold;">The ${brand_name} Team</p>
223
  <p>
224
  <small>
 
1
  <!DOCTYPE html>
2
  <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Your Personalized Style Curation</title>
7
+ <style>
8
+ /* Adjusted colors for better visibility */
9
+ body {
10
+ margin: 0;
11
+ padding: 0;
12
+ width: 100%;
13
+ font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
14
+ line-height: 1.6;
15
+ color: #2C2C2C; /* Darker gray for better contrast */
16
+ background-color: #FAF9F6; /* Light neutral background */
17
+ }
18
+
19
+ .nlbackgroundcontainer {
20
+ max-width: 600px;
21
+ margin: 0 auto;
22
+ padding: 30px;
23
+ background-color: #FFFFFF;
24
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
25
+ border: 1px solid #DDDDDD; /* Neutral border */
26
+ }
27
+
28
+ .nlheader {
29
+ text-align: center;
30
+ padding: 20px 0;
31
+ border-bottom: 1px solid #CCCCCC;
32
+ margin-bottom: 30px;
33
+ }
34
+
35
+ .nlheader img {
36
+ max-width: 200px;
37
+ height: auto;
38
+ }
39
+
40
+ .nlsection {
41
+ margin-bottom: 40px;
42
+ }
43
+
44
+ h1, h2, h3 {
45
+ font-family: 'Didot', serif;
46
+ color: #333333; /* Dark neutral tone for headings */
47
+ margin-bottom: 15px;
48
+ }
49
+
50
+ .nlsection-row {
51
+ display: flex;
52
+ flex-wrap: wrap;
53
+ justify-content: space-between;
54
+ gap: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
  .bought-item, .product {
58
+ display: flex;
59
+ flex-direction: column;
60
+ align-items: center;
61
+ width: calc(50% - 10px);
62
  margin: 10px 0;
63
+ text-align: center;
64
+ padding: 20px;
65
+ background-color: #F9F9F9;
66
+ border-radius: 8px;
67
+ border: 1px solid #DDDDDD;
68
+ transition: transform 0.3s ease;
69
  }
70
+
71
+ @media screen and (max-width: 600px) {
72
+ .nlsection-row {
73
+ flex-direction: column;
74
+ }
75
+
76
+ .bought-item, .product {
77
+ width: 100%;
78
+ margin: 10px 0;
79
+ }
80
+ }
81
+
82
+ .bought-item:hover, .product:hover {
83
+ transform: scale(1.02);
84
+ box-shadow: 0 4px 6px rgba(0,0,0,0.1);
85
+ }
86
+
87
+ .deal-box {
88
+ background-color: #F4F4F4;
89
+ color: #333333;
90
+ padding: 20px;
91
+ margin: 15px 0;
92
+ border-radius: 8px;
93
+ text-align: center;
94
+ border: 1px solid #CCCCCC;
95
+ }
96
+
97
+ .nlbutton {
98
+ display: inline-block;
99
+ padding: 12px 25px;
100
+ background-color: #5A5A5A; /* Neutral dark button */
101
+ color: #FFFFFF;
102
+ text-decoration: none;
103
+ border-radius: 5px;
104
+ font-weight: 600;
105
+ text-transform: uppercase;
106
+ letter-spacing: 1px;
107
+ transition: background-color 0.3s ease;
108
+ }
109
+
110
+ .nlbutton:hover {
111
+ background-color: #333333; /* Slightly darker on hover */
112
+ }
113
+
114
+ .nlfooter {
115
+ text-align: center;
116
+ padding: 20px;
117
+ background-color: #F4F4F4;
118
+ border-top: 1px solid #CCCCCC;
119
+ font-size: 0.9em;
120
+ }
121
+
122
+ a {
123
+ color: #5A5A5A; /* Neutral dark links */
124
+ text-decoration: none;
125
+ }
126
+
127
+ a:hover {
128
+ text-decoration: underline;
129
+ }
130
+ </style>
131
+ </head>
 
 
 
 
132
  <body>
133
+ <div class="nlbackgroundcontainer">
134
+ <!-- nlheader nlsection -->
135
+ <div class="nlheader" style="display: flex; justify-content: center; align-items: center;">
136
  <img src="${brand_logo}" alt="Brand Logo">
137
  </div>
138
 
139
  <!-- Personal Greeting -->
140
+ <div class="nlsection">
141
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; line-height: 1.5; color: #333; letter-spacing: 0.5px; text-align: left;">
142
  ${greeting} </p>
143
  </div>
144
 
145
+ <!-- Previously Bought Items nlsection -->
146
+ <div class="nlsection">
147
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; color: #333; line-height: 1.5; letter-spacing: 0.5px; text-align: left;"> ${intro} </p>
148
+ <div class="nlsection-row">
149
  <div class="bought-item">
150
  <img src= ${transaction_url} alt="Previous Product 1">
151
  <h3> ${transaction_name} </h3>
 
160
  <!-- Recommended Items -->
161
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; color: #333; line-height: 1.5; letter-spacing: 0.5px; text-align: left;">
162
  ${recommendations} </p>
163
+ <div class="nlsection">
164
+ <div class="nlsection-row">
165
  <div class="product">
166
  <img src=${recommendation_url} alt="Recommended Product 1">
167
  <h3>${recommendation_name}</h3>
168
+ <a href="#" class="nlbutton" >Explore</a>
169
  </div>
170
  <div class="product">
171
  <img src=${recommendation_url} alt="Recommended Product 2">
172
  <h3>${recommendation_name}</h3>
173
+ <a href="#" class="nlbutton">Explore</a>
174
  </div>
175
  </div>
176
  </div>
177
 
178
+ <!-- Deals nlsection -->
179
+ <div class="nlsection">
180
  <h2 style="color: #8B6914;">Not Your Style?</h2>
181
  <p style="font-size: 18px; font-family: 'Georgia', 'Times New Roman', serif; font-style: italic; color: #333; line-height: 1.5; letter-spacing: 0.5px; text-align: left;">
182
  Well, I always try my best and recommend what I think would suit you well, but hey, we all make mistakes, right? </p>
 
195
  </div>
196
 
197
  <!-- Call to Action -->
198
+ <div class="nlsection" style="text-align: center;">
199
  <h2>Ready to Refine Your Wardrobe?</h2>
200
+ <a href="#" class="nlbutton">View New Arrivals</a>
201
+ <a href="#" class="nlbutton" style="background-color: #5D4037;">Book Styling Consultation</a>
202
  </div>
203
 
204
+ <!-- nlfooter -->
205
+ <div class="nlfooter">
206
  <p style="font-weight: bold;">The ${brand_name} Team</p>
207
  <p>
208
  <small>
src/utils_api.py CHANGED
@@ -143,6 +143,8 @@ def get_recommendations(customer_ids, max_recs=4, max_transactions=2):
143
  recommendations = make_api_request("get-recommendations", customer_ids)
144
  if recommendations:
145
  return parse_recommendations(recommendations, max_recs, max_transactions)
 
 
146
  return None
147
 
148
 
 
143
  recommendations = make_api_request("get-recommendations", customer_ids)
144
  if recommendations:
145
  return parse_recommendations(recommendations, max_recs, max_transactions)
146
+ else:
147
+ raise ValueError("Error occurred while fetching recommendations.")
148
  return None
149
 
150