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