nniehaus commited on
Commit
4675bce
Β·
verified Β·
1 Parent(s): 16584c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +126 -54
app.py CHANGED
@@ -81,12 +81,15 @@ def analyze_home_photos(images, timeframe, additional_details, api_key):
81
  ## FORMAT YOUR RESPONSE LIKE THIS:
82
 
83
  ### πŸ“‹ KEY RECOMMENDATIONS SUMMARY
84
- Begin with a brief introduction that states: "Here's a concise summary of the top improvements to maximize your home's value. Detailed explanations, specific costs, and a complete timeline can be found in the sections below."
85
 
86
- Then, list 5 bullet points of the MOST IMPACTFUL improvements that will increase the property's value. Each point should be 1-2 sentences only and include:
87
- - The specific issue identified
88
- - The recommended solution
89
- - The estimated value increase or ROI
 
 
 
90
 
91
  ### 🌟 TOP PRICE-MAXIMIZING PRIORITIES
92
  Present the 3-4 MOST IMPACTFUL improvements first, formatted as a clear list. Each item MUST include:
@@ -213,54 +216,55 @@ def calculate_cost(token_usage):
213
  "total_cost": total_cost
214
  }
215
 
216
- # Main application - more compact header
217
  st.markdown("""
218
  <style>
219
- /* Make the title and header compact */
220
- .main .block-container {padding-top: 1rem !important;}
221
- h1 {margin-top: 0 !important; margin-bottom: 0.2rem !important; font-size: 1.8rem !important;}
 
 
 
222
 
223
- /* Remove spacing after description */
224
- .compact-text {margin-bottom: 0.5rem !important; line-height: 1.2 !important;}
 
 
 
 
225
 
226
- /* Reduced column gap */
227
- .st-emotion-cache-ocqkz7 {gap: 1rem !important;}
 
 
 
 
228
 
229
- /* Remove default margin from subheadings */
230
- .stSubheader {margin-bottom: 0.5rem !important;}
231
- </style>
232
-
233
- <h1>Home Value Maximizer 🏑</h1>
234
- <div class="compact-text">
235
- πŸ“Έ Upload photos β†’ πŸ’° Get specific improvements β†’ 🏑 Maximize selling price
236
- </div>
237
- """, unsafe_allow_html=True)
238
-
239
- # VERY compact instructions - inline with columns
240
- col_inst_1, col_inst_2, col_inst_3 = st.columns(3)
241
- with col_inst_1:
242
- st.markdown("<small>1. Upload multiple photos of your home</small>", unsafe_allow_html=True)
243
- with col_inst_2:
244
- st.markdown("<small>2. Enter your selling timeline & preferences</small>", unsafe_allow_html=True)
245
- with col_inst_3:
246
- st.markdown("<small>3. Click 'Analyze My Home' for detailed strategies</small>", unsafe_allow_html=True)
247
-
248
- # Enhanced CSS for better formatting of the recommendations
249
- st.markdown("""
250
- <style>
251
- .main .block-container {padding-bottom: 5rem !important; max-width: 100% !important;}
252
-
253
- /* Responsive styling */
254
- @media (max-width: 640px) {
255
- .main .block-container {padding: 1rem 0.5rem !important;}
256
- h1 {font-size: 1.5rem !important;}
257
- h2, h3 {font-size: 1.2rem !important;}
258
- .stButton button {width: 100% !important; height: 3rem !important;}
259
  }
260
 
261
- /* Remove extra space */
262
- .st-emotion-cache-16txtl3 p {
263
- margin-bottom: 0.5rem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  }
265
 
266
  /* Enhanced section styling */
@@ -272,11 +276,26 @@ st.markdown("""
272
  color: white;
273
  }
274
 
275
- /* Summary section */
276
  .stMarkdown h3:contains("KEY RECOMMENDATIONS SUMMARY") {
277
  background-color: #2196f3;
278
  }
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  /* Priority recommendations */
281
  .stMarkdown h3:contains("TOP PRICE") {
282
  background-color: #1e88e5;
@@ -312,7 +331,7 @@ st.markdown("""
312
  background-color: #8e24aa;
313
  }
314
 
315
- /* List styling */
316
  .stMarkdown ul li {
317
  margin-bottom: 0.75rem;
318
  line-height: 1.6;
@@ -320,7 +339,7 @@ st.markdown("""
320
 
321
  /* Bold text */
322
  .stMarkdown strong {
323
- color: #263238;
324
  font-weight: 700;
325
  }
326
 
@@ -341,9 +360,42 @@ st.markdown("""
341
  font-size: 0.85rem;
342
  margin-top: 1rem;
343
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
  </style>
345
  """, unsafe_allow_html=True)
346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  # API Key input if not in secrets
348
  if not st.session_state["api_key"]:
349
  st.session_state["api_key"] = st.text_input("Enter your OpenAI API Key", type="password")
@@ -353,7 +405,8 @@ if not st.session_state["api_key"]:
353
  col1, col2 = st.columns(2)
354
 
355
  with col1:
356
- st.subheader("πŸ“Έ Upload Home Photos")
 
357
  uploaded_files = st.file_uploader("Upload photos of different areas of your home",
358
  accept_multiple_files=True,
359
  type=["jpg", "jpeg", "png"])
@@ -382,7 +435,8 @@ with col1:
382
  with image_cols[i % min(3, len(images))]:
383
  st.image(img, width=150, caption=f"Image {i+1}")
384
 
385
- st.subheader("🏠 Selling Timeline & Details")
 
386
 
387
  # Expanded selling timeline options
388
  timeframe = st.radio("When do you plan to sell your home?",
@@ -392,8 +446,8 @@ with col1:
392
  placeholder="Describe your home, local market conditions, target buyers, or any specific concerns you have about the selling process.",
393
  height=100)
394
 
395
- # Additional preferences
396
- st.subheader("πŸ’° Budget & Preferences")
397
 
398
  max_budget = st.slider("Maximum budget for improvements ($)",
399
  min_value=1000,
@@ -425,7 +479,8 @@ with col1:
425
  st.warning("Please enter your OpenAI API key to enable analysis.")
426
 
427
  with col2:
428
- st.subheader("πŸ’‘ Comprehensive Selling Strategies")
 
429
 
430
  # Process and display analysis results
431
  if analyze_button or "analysis_result" in st.session_state:
@@ -470,7 +525,24 @@ with col2:
470
 
471
  # Display results
472
  if "analysis_result" in st.session_state:
 
473
  result = st.session_state["analysis_result"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
  st.markdown(f'<div class="results-container">{result}</div>', unsafe_allow_html=True)
475
 
476
  # Show token usage and cost information
 
81
  ## FORMAT YOUR RESPONSE LIKE THIS:
82
 
83
  ### πŸ“‹ KEY RECOMMENDATIONS SUMMARY
84
+ Begin with this exact text: "**HOME VALUE MAXIMIZER SUMMARY**"
85
 
86
+ Then add this line: "Below are the top improvements to maximize your home's value. See detailed sections for specific costs, instructions, and timeline."
87
+
88
+ Then, list 5 bullet points of the MOST IMPACTFUL improvements that will increase the property's value. For each bullet:
89
+ - Make the first sentence **bold**
90
+ - Include the specific issue identified
91
+ - Include the recommended solution
92
+ - Include the estimated value increase or ROI
93
 
94
  ### 🌟 TOP PRICE-MAXIMIZING PRIORITIES
95
  Present the 3-4 MOST IMPACTFUL improvements first, formatted as a clear list. Each item MUST include:
 
216
  "total_cost": total_cost
217
  }
218
 
219
+ # Custom CSS to fix all styling issues including text visibility
220
  st.markdown("""
221
  <style>
222
+ /* Override streamlit's default padding */
223
+ .main .block-container {
224
+ padding-top: 1rem !important;
225
+ padding-bottom: 1rem !important;
226
+ max-width: 100% !important;
227
+ }
228
 
229
+ /* Fix text visibility issues - ensure good contrast */
230
+ .upload-text {
231
+ color: #262730 !important;
232
+ background-color: transparent !important;
233
+ font-weight: 500 !important;
234
+ }
235
 
236
+ /* Make the title and header area more compact */
237
+ .title-area {
238
+ margin: 0 !important;
239
+ padding: 0 !important;
240
+ margin-bottom: 0.5rem !important;
241
+ }
242
 
243
+ /* Make header more compact */
244
+ .stMarkdown h1 {
245
+ margin-top: 0 !important;
246
+ margin-bottom: 0.2rem !important;
247
+ font-size: 1.8rem !important;
248
+ padding: 0 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
250
 
251
+ /* Steps styling */
252
+ .steps-container {
253
+ display: flex;
254
+ justify-content: space-between;
255
+ margin-bottom: 1rem !important;
256
+ padding: 0 !important;
257
+ }
258
+
259
+ .step-item {
260
+ flex: 1;
261
+ padding: 0.3rem 0.5rem;
262
+ font-size: 0.85rem;
263
+ color: #262730;
264
+ background-color: #f0f2f6;
265
+ border-radius: 4px;
266
+ margin-right: 0.5rem;
267
+ text-align: center;
268
  }
269
 
270
  /* Enhanced section styling */
 
276
  color: white;
277
  }
278
 
279
+ /* Style for summary section */
280
  .stMarkdown h3:contains("KEY RECOMMENDATIONS SUMMARY") {
281
  background-color: #2196f3;
282
  }
283
 
284
+ /* Summary content styling */
285
+ .summary-title {
286
+ font-size: 1.2rem;
287
+ font-weight: bold;
288
+ margin-bottom: 0.5rem;
289
+ color: #2196f3;
290
+ }
291
+
292
+ .summary-subtitle {
293
+ font-size: 0.9rem;
294
+ font-weight: 500;
295
+ margin-bottom: 1rem;
296
+ color: #424242;
297
+ }
298
+
299
  /* Priority recommendations */
300
  .stMarkdown h3:contains("TOP PRICE") {
301
  background-color: #1e88e5;
 
331
  background-color: #8e24aa;
332
  }
333
 
334
+ /* Style for bullet points in summary */
335
  .stMarkdown ul li {
336
  margin-bottom: 0.75rem;
337
  line-height: 1.6;
 
339
 
340
  /* Bold text */
341
  .stMarkdown strong {
342
+ color: #262730;
343
  font-weight: 700;
344
  }
345
 
 
360
  font-size: 0.85rem;
361
  margin-top: 1rem;
362
  }
363
+
364
+ /* Blue background for summary section */
365
+ .summary-section {
366
+ background-color: #e3f2fd;
367
+ border-radius: 8px;
368
+ padding: 1rem;
369
+ margin-bottom: 1.5rem;
370
+ border-left: 4px solid #2196f3;
371
+ }
372
+
373
+ /* Custom header style for subheaders */
374
+ .custom-subheader {
375
+ background-color: #f5f5f5;
376
+ padding: 10px;
377
+ border-radius: 5px;
378
+ margin-bottom: 10px;
379
+ color: #262730;
380
+ font-weight: 600;
381
+ }
382
  </style>
383
  """, unsafe_allow_html=True)
384
 
385
+ # Custom compact header
386
+ st.markdown("""
387
+ <div class="title-area">
388
+ <h1>Home Value Maximizer 🏑</h1>
389
+ <div class="upload-text">πŸ“Έ Upload photos β†’ πŸ’° Get specific improvements β†’ 🏑 Maximize selling price</div>
390
+ </div>
391
+
392
+ <div class="steps-container">
393
+ <div class="step-item">1. Upload multiple photos of your home</div>
394
+ <div class="step-item">2. Enter your selling timeline & preferences</div>
395
+ <div class="step-item">3. Click 'Analyze My Home' for detailed strategies</div>
396
+ </div>
397
+ """, unsafe_allow_html=True)
398
+
399
  # API Key input if not in secrets
400
  if not st.session_state["api_key"]:
401
  st.session_state["api_key"] = st.text_input("Enter your OpenAI API Key", type="password")
 
405
  col1, col2 = st.columns(2)
406
 
407
  with col1:
408
+ # Custom subheader with background
409
+ st.markdown('<div class="custom-subheader">πŸ“Έ Upload Home Photos</div>', unsafe_allow_html=True)
410
  uploaded_files = st.file_uploader("Upload photos of different areas of your home",
411
  accept_multiple_files=True,
412
  type=["jpg", "jpeg", "png"])
 
435
  with image_cols[i % min(3, len(images))]:
436
  st.image(img, width=150, caption=f"Image {i+1}")
437
 
438
+ # Custom subheader with background
439
+ st.markdown('<div class="custom-subheader">🏠 Selling Timeline & Details</div>', unsafe_allow_html=True)
440
 
441
  # Expanded selling timeline options
442
  timeframe = st.radio("When do you plan to sell your home?",
 
446
  placeholder="Describe your home, local market conditions, target buyers, or any specific concerns you have about the selling process.",
447
  height=100)
448
 
449
+ # Additional preferences with custom subheader
450
+ st.markdown('<div class="custom-subheader">πŸ’° Budget & Preferences</div>', unsafe_allow_html=True)
451
 
452
  max_budget = st.slider("Maximum budget for improvements ($)",
453
  min_value=1000,
 
479
  st.warning("Please enter your OpenAI API key to enable analysis.")
480
 
481
  with col2:
482
+ # Custom subheader with background
483
+ st.markdown('<div class="custom-subheader">πŸ’‘ Comprehensive Selling Strategies</div>', unsafe_allow_html=True)
484
 
485
  # Process and display analysis results
486
  if analyze_button or "analysis_result" in st.session_state:
 
525
 
526
  # Display results
527
  if "analysis_result" in st.session_state:
528
+ # Process the output to enhance summary formatting
529
  result = st.session_state["analysis_result"]
530
+
531
+ # Check if we need to style the summary section
532
+ if "**HOME VALUE MAXIMIZER SUMMARY**" in result:
533
+ # Split the result to find the summary section
534
+ parts = result.split("### πŸ“‹ KEY RECOMMENDATIONS SUMMARY", 1)
535
+ if len(parts) > 1:
536
+ before_summary = parts[0]
537
+ rest_parts = parts[1].split("### 🌟", 1)
538
+ if len(rest_parts) > 1:
539
+ summary_content = rest_parts[0]
540
+ after_summary = "### 🌟" + rest_parts[1]
541
+
542
+ # Apply custom formatting to the summary
543
+ result = before_summary + '<div class="summary-section">' + summary_content + '</div>' + after_summary
544
+
545
+ # Display the enhanced result
546
  st.markdown(f'<div class="results-container">{result}</div>', unsafe_allow_html=True)
547
 
548
  # Show token usage and cost information