Files changed (1) hide show
  1. app.py +63 -0
app.py CHANGED
@@ -53,3 +53,66 @@ if st.button("Generate Image"):
53
  st.error(f"Error: {e}")
54
  else:
55
  st.warning("Please enter a valid prompt.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  st.error(f"Error: {e}")
54
  else:
55
  st.warning("Please enter a valid prompt.")
56
+ # === Agent 3: Material Explorer ===
57
+ import json
58
+
59
+ st.header("Agent 3: Material Explorer")
60
+
61
+ # Optionally use DALL·E prompt if needed (or use layout summary from Agent 1/2)
62
+ your_dalle_prompt = st.session_state.get("requirements_summary", "")
63
+
64
+ if st.button("Get Suggested Materials"):
65
+ with st.spinner("Using Gemini to extract materials..."):
66
+
67
+ material_prompt = f"""
68
+ From the following blueprint prompt and layout concept:
69
+
70
+ Blueprint Prompt:
71
+ \"\"\"{your_dalle_prompt}\"\"\"
72
+
73
+ Return 5 key building materials implied by the layout, even if not explicitly listed.
74
+
75
+ Respond ONLY with a raw JSON list like:
76
+ ["Concrete slab foundation", "Metal roofing", "Plywood sheathing", "Double-pane windows", "Insulation"]
77
+ """
78
+
79
+ model = genai.GenerativeModel("gemini-1.5-pro")
80
+ response = model.generate_content(material_prompt)
81
+ raw = response.text.strip()
82
+
83
+ import re
84
+ cleaned = re.sub(r"```json|```", "", raw).strip()
85
+
86
+ try:
87
+ materials = json.loads(cleaned)
88
+ st.session_state.materials = materials
89
+ st.success("✅ Materials extracted.")
90
+ except Exception as e:
91
+ st.error("❌ Could not parse Gemini response.")
92
+ st.code(raw)
93
+ materials = []
94
+ # Hardcoded URL map
95
+ material_links = {
96
+ "Engineered wood flooring": "https://www.homedepot.ca/product/home-decorators-collection-laminate-flooring-castle-oak/1001624267",
97
+ "Laminate countertops": "https://www.homedepot.ca/product/hampton-bay-premium-laminate-countertop-butchers-block/1001185104",
98
+ "Tile (bathroom)": "https://www.homedepot.ca/product/enigma-12-inch-x-24-inch-glazed-porcelain-tile-aria-grey/1001066513",
99
+ "Painted drywall": "https://www.homedepot.ca/product/certainteed-1-2-inch-x-4-ft-x-8-ft-drywall/1000116648",
100
+ "Wood framing (stud walls)": "https://www.homedepot.ca/product/2-inch-x-4-inch-x-8-ft-construction-grade-lumber/1000115194",
101
+ "Spray foam insulation": "https://www.homedepot.ca/product/great-stuff-big-gap-filler-insulating-foam-sealant-12-oz/1000110899",
102
+ "Triple-glazed windows": "https://www.homedepot.ca/product/american-craftsman-60-inch-x-60-inch-double-pane-double-hung-vinyl-window/1001202871",
103
+ "Metal roofing": "https://www.homedepot.ca/product/ondura-36-inch-x-79-inch-black-roof-panel/1000167679",
104
+ "Solar panel kit": "https://www.homedepot.ca/product/nature-power-110-watt-solar-panel-kit-with-inverter-and-charging-controller/1001037002",
105
+ "Mini wood stove": "https://www.homedepot.ca/product/englander-1-200-sq-ft-wood-burning-stove/1000829230"
106
+ }
107
+
108
+ # Show material links
109
+ if "materials" in st.session_state:
110
+ st.subheader("🔗 Explore Real-World Materials")
111
+
112
+ for mat in st.session_state.materials:
113
+ url = material_links.get(mat)
114
+ if url:
115
+ st.markdown(f"✅ **{mat}**: [View on Home Depot]({url})", unsafe_allow_html=True)
116
+ else:
117
+ st.markdown(f"🟡 **{mat}**: _(no link available)_")
118
+