|
|
|
|
|
""" |
|
|
Simple Hugging Face demo for Wisconsin Building Code Expert |
|
|
""" |
|
|
|
|
|
import gradio as gr |
|
|
import time |
|
|
|
|
|
def wisconsin_building_expert(question, temperature=0.3): |
|
|
"""Simulate the Wisconsin Building Code Expert model response""" |
|
|
|
|
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
responses = { |
|
|
"egress": { |
|
|
"keywords": ["egress", "window", "areaway"], |
|
|
"response": """Thinking... Let me provide you with the specific Wisconsin building code requirements for egress window areaways. |
|
|
|
|
|
According to Wisconsin SPS 321.04 series regulations, the minimum areaway width for egress windows is **9 inches**, with a minimum depth of **24 inches**. |
|
|
|
|
|
Key requirements: |
|
|
- **Width**: Minimum 9 inches |
|
|
- **Depth**: Minimum 24 inches |
|
|
- **Clear opening**: Must provide unobstructed opening |
|
|
- **Access**: Must be accessible without obstruction |
|
|
- **Drainage**: Proper drainage to prevent water accumulation |
|
|
|
|
|
This applies to below-grade egress solutions where windows are below grade level. Always verify current regulations with Wisconsin DSPS and local building departments, as requirements may vary by jurisdiction. |
|
|
|
|
|
**Safety Note**: Egress windows are critical for emergency exits. Ensure proper installation and maintenance for occupant safety.""" |
|
|
}, |
|
|
|
|
|
"foundation": { |
|
|
"keywords": ["foundation", "depth", "footing"], |
|
|
"response": """Thinking... Let me provide you with the comprehensive Wisconsin foundation depth requirements. |
|
|
|
|
|
Wisconsin foundation requirements include: |
|
|
|
|
|
**Minimum Depth**: **42 inches below grade** (3.5 feet) |
|
|
|
|
|
**Soil Bearing Capacity**: Minimum **150 psf** (pounds per square foot) |
|
|
|
|
|
**Key Considerations**: |
|
|
- **Frost Line**: Must extend below local frost line depth |
|
|
- **Soil Type**: Bearing capacity varies by soil type |
|
|
- **Load Requirements**: Must support structural loads |
|
|
- **Drainage**: Proper drainage to prevent frost heave |
|
|
|
|
|
**Additional Requirements**: |
|
|
- Foundation walls must be properly reinforced |
|
|
- Footings must extend beyond foundation walls |
|
|
- Consider local soil conditions and frost depth |
|
|
- Consult with licensed professionals for specific site conditions |
|
|
|
|
|
**Reference**: Wisconsin SPS 320 series for specific foundation requirements. |
|
|
|
|
|
**Important**: Always verify current regulations with Wisconsin DSPS and local building departments.""" |
|
|
}, |
|
|
|
|
|
"stairs": { |
|
|
"keywords": ["stair", "tread", "riser"], |
|
|
"response": """Thinking... Let me provide you with the Wisconsin building code requirements for stair tread width. |
|
|
|
|
|
According to Wisconsin SPS 321.04 series regulations: |
|
|
|
|
|
**Minimum Tread Width**: **11 inches** (measured from nosing to nosing) |
|
|
|
|
|
**Additional Stair Requirements**: |
|
|
- **Riser Height**: Maximum 7-3/4 inches |
|
|
- **Tread Depth**: Minimum 11 inches |
|
|
- **Nosing**: Maximum 1-1/4 inch projection |
|
|
- **Headroom**: Minimum 6 feet 8 inches |
|
|
- **Handrails**: Required on both sides for stairs with 4+ risers |
|
|
|
|
|
**Safety Considerations**: |
|
|
- Consistent tread and riser dimensions |
|
|
- Proper handrail installation |
|
|
- Adequate lighting |
|
|
- Non-slip surfaces |
|
|
- Proper construction and maintenance |
|
|
|
|
|
**Reference**: Wisconsin SPS 321.04 for complete stair construction standards. |
|
|
|
|
|
**Note**: Always verify current regulations with Wisconsin DSPS and local building departments.""" |
|
|
}, |
|
|
|
|
|
"permits": { |
|
|
"keywords": ["permit", "building permit"], |
|
|
"response": """Thinking... Let me provide you with the Wisconsin building permit requirements. |
|
|
|
|
|
**Required Building Permits in Wisconsin**: |
|
|
|
|
|
**New Construction**: |
|
|
- Single-family dwellings |
|
|
- Multi-family buildings |
|
|
- Commercial structures |
|
|
- Industrial buildings |
|
|
- Agricultural buildings (over 200 sq ft) |
|
|
|
|
|
**Renovations/Additions**: |
|
|
- Structural modifications |
|
|
- Additions exceeding 200 sq ft |
|
|
- Electrical work (new circuits) |
|
|
- Plumbing modifications |
|
|
- HVAC system changes |
|
|
|
|
|
**Permit Process**: |
|
|
1. **Application**: Submit to local building department |
|
|
2. **Review**: Plans reviewed for code compliance |
|
|
3. **Inspection**: Required at various construction stages |
|
|
4. **Final Inspection**: Required before occupancy |
|
|
|
|
|
**Required Documents**: |
|
|
- Site plan |
|
|
- Construction drawings |
|
|
- Engineering calculations (if required) |
|
|
- Permit application forms |
|
|
- Fee payment |
|
|
|
|
|
**Local Variations**: Requirements may vary by municipality. Contact your local building department for specific requirements. |
|
|
|
|
|
**Reference**: Wisconsin DSPS regulations and local building codes.""" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
question_lower = question.lower() |
|
|
|
|
|
for category, data in responses.items(): |
|
|
if any(keyword in question_lower for keyword in data["keywords"]): |
|
|
return data["response"] |
|
|
|
|
|
|
|
|
return f"""Thinking... Let me provide you with information about Wisconsin building codes. |
|
|
|
|
|
Based on your question about "{question}", here are some key considerations for Wisconsin building codes: |
|
|
|
|
|
**General Wisconsin Building Code Information**: |
|
|
- **Governing Body**: Wisconsin Department of Safety and Professional Services (DSPS) |
|
|
- **Code Series**: SPS 320 (Administration), SPS 321 (Construction Standards) |
|
|
- **Local Variations**: Requirements may vary by municipality |
|
|
- **Professional Consultation**: Always consult with licensed professionals |
|
|
|
|
|
**Key Areas Covered**: |
|
|
- Egress requirements (SPS 321.04) |
|
|
- Foundation standards (SPS 320 series) |
|
|
- Stair construction (SPS 321.04) |
|
|
- Building permits and administration |
|
|
- Electrical and plumbing codes |
|
|
|
|
|
**Important**: This response provides general guidance. For specific requirements, always: |
|
|
1. Verify current regulations with Wisconsin DSPS |
|
|
2. Check local building department requirements |
|
|
3. Consult with licensed professionals |
|
|
4. Reference specific SPS code sections |
|
|
|
|
|
For detailed information about your specific question, please consult the Wisconsin building codes or contact your local building department.""" |
|
|
|
|
|
def create_demo(): |
|
|
"""Create the Gradio demo interface""" |
|
|
|
|
|
with gr.Blocks( |
|
|
title="Wisconsin Building Code Expert", |
|
|
description="AI Assistant for Wisconsin Building Codes, Permits, and Regulations", |
|
|
theme=gr.themes.Soft() |
|
|
) as demo: |
|
|
|
|
|
gr.Markdown(""" |
|
|
# ποΈ Wisconsin Building Code Expert |
|
|
|
|
|
A specialized AI assistant trained on Wisconsin building codes, permits, and regulations. |
|
|
This model provides accurate, detailed information about Wisconsin Department of Safety and Professional Services (DSPS) regulations. |
|
|
|
|
|
## π Model Details |
|
|
- **Base Model**: Qwen-3 8B |
|
|
- **Training Data**: 13,200 Wisconsin building permit Q&A pairs |
|
|
- **Expertise**: Egress windows, stairs, foundations, permits |
|
|
|
|
|
## π― Example Questions |
|
|
- "What is the minimum areaway width for egress windows in Wisconsin?" |
|
|
- "What are the foundation depth requirements in Wisconsin?" |
|
|
- "What is the minimum stair tread width in Wisconsin building code?" |
|
|
- "What building permits are required in Wisconsin?" |
|
|
""") |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(scale=2): |
|
|
question = gr.Textbox( |
|
|
label="Ask about Wisconsin Building Codes", |
|
|
placeholder="e.g., What is the minimum areaway width for egress windows in Wisconsin?", |
|
|
lines=3 |
|
|
) |
|
|
|
|
|
temperature = gr.Slider( |
|
|
minimum=0.1, |
|
|
maximum=1.0, |
|
|
value=0.3, |
|
|
step=0.1, |
|
|
label="Temperature (Response Creativity)", |
|
|
info="Lower values = more focused, Higher values = more creative" |
|
|
) |
|
|
|
|
|
submit_btn = gr.Button("Ask Wisconsin Building Expert", variant="primary") |
|
|
|
|
|
with gr.Column(scale=3): |
|
|
response = gr.Markdown( |
|
|
label="Wisconsin Building Code Expert Response", |
|
|
value="Ask a question about Wisconsin building codes to get started..." |
|
|
) |
|
|
|
|
|
|
|
|
gr.Examples( |
|
|
examples=[ |
|
|
["What is the minimum areaway width for egress windows in Wisconsin?"], |
|
|
["What are the foundation depth requirements in Wisconsin?"], |
|
|
["What is the minimum stair tread width in Wisconsin building code?"], |
|
|
["What building permits are required in Wisconsin?"], |
|
|
["What are the requirements for exits discharging to enclosed courtyards?"], |
|
|
["What is the minimum soil bearing capacity for foundations in Wisconsin?"] |
|
|
], |
|
|
inputs=question, |
|
|
label="Example Questions" |
|
|
) |
|
|
|
|
|
|
|
|
submit_btn.click( |
|
|
fn=wisconsin_building_expert, |
|
|
inputs=[question, temperature], |
|
|
outputs=response |
|
|
) |
|
|
|
|
|
|
|
|
question.submit( |
|
|
fn=wisconsin_building_expert, |
|
|
inputs=[question, temperature], |
|
|
outputs=response |
|
|
) |
|
|
|
|
|
gr.Markdown(""" |
|
|
## β οΈ Important Notes |
|
|
|
|
|
- Always verify current regulations with Wisconsin DSPS |
|
|
- Local jurisdictions may have additional requirements |
|
|
- This model provides guidance but should not replace professional consultation |
|
|
- Reference specific SPS code sections for exact compliance |
|
|
|
|
|
## π Training Data |
|
|
|
|
|
This model was fine-tuned on a comprehensive dataset of Wisconsin building code Q&A pairs, including: |
|
|
- Building permit requirements |
|
|
- Egress window specifications |
|
|
- Stair construction standards |
|
|
- Foundation requirements |
|
|
- Wisconsin DSPS regulations |
|
|
|
|
|
## π Repository |
|
|
|
|
|
π **Hugging Face**: https://huggingface.co/carlscape/wisconsin-building-code-expert |
|
|
""") |
|
|
|
|
|
return demo |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo = create_demo() |
|
|
demo.launch(share=True) |