Agentic RAG [Building Inspector]

This hands-on use case enables participants to develop an intelligent city building inspector that reviews architectural blueprints and construction floorplans for compliance with City of Miami Building Codes.

Use Case

Build a smart compliance analysis agent that interprets building floorplans and verifies them against the City of Miami’s building regulations, providing detailed code assessments, violation detection, and corrective recommendations.

Prerequisites

  • The Building code dataset is pre-created by the Administrator.

  • Basic familiarity with the platform interface.

  • Ensure that all participants have access to the Karini AI platform.

Step 1: Create an Building Inspector Agent prompt

  1. Navigate to Prompt Playground.

  2. Click Add New in the top corner and select Task as Agent.

  3. Click on Prompt templates and Select the Building Inspector template to use.

  4. Once the template is added to the prompt, scroll up to increase the Max State Updates from 3 to 20 for complex reasoning.

  5. Add the following test query to the Agent Input box: "What is the minimum ceiling height for basement?"

  6. Ensure that you scroll up to rename your prompt with your initials .

  7. Save the prompt.

  8. You will be directed to the Prompt Playground and select your working prompt:

    • Click on the Tools tab to configure the following tools:

    [Hint: Please Save your Changes before you navigate away while adding new tools ]

  • Dataset Tool

    • Click Add New to a create new tool.

    • Name: "Building code knowledgebase".

    • Description: "This tool provides access to comprehensive information about the city of Miami building codes including codes, descriptions, measurements, dimensions, rules, regulations, causes, exemptions for the building plans. It requires the agent to input the natural language question to obtain relevant information.".

    • Type: Dataset

    • Select the pre-created Building code dataset.

    • In the Prompt context section, Select Use Embedding chunks.

    • Set the following options for context retrieval:

      • Top-K = 4.

      • Enable Advanced query reconstruction and select Query expansion.

      • Save the tool.

Test & Compare:

  1. In Test & Compare tab, select different models from the dropdown to test the prompt [Hint: Compare Claude Sonnet 3.7, Claude Sonnet 3.5 v2, Anthropic Claude Sonnet 4].

  2. Test and compare the agent responses with the selected models.

  3. Click on Select as best answer with "Claude Sonnet 3.5 v2" to select the best-performing model as the Primary Model.

  4. Optionally Select as best answer to assign a Fallback Model.

  5. Click the Save prompt run in the right corner to save the prompt run.

  6. Save and publish the prompt.

Note: Only published prompts are visible in the recipe.

Refer to the following video to create and test agent prompt.

Step 2: Create an Agent 2.0 Recipe

  1. Navigate to the Recipes section on the left side.

  2. Click Add New in the top right corner to create a new recipe.

  3. Configure recipe details:

    1. Name: "Building Inspector Agent".

    2. Type: Agent 2.0.

  4. Set up the the recipe workflow nodes by selecting each of the following elements and dragging them onto the recipe canvas:

    1. Chat/Draft:

      • Configure to retain 2 messages from the conversation history.

      • Enable Generate follow-up questions to generate follow-up questions.

      • Enable citations.

    2. Processing:

      1. Enable the OCR option and select VLM.

      2. And use following prompt in VLM Prompt.

# Optimized Floor Plan Data Extraction Prompt

## Instruction: 
Analyze this floor plan image systematically and extract all visible information. Follow this exact sequence:

### 1. Text Extraction (Read Everything Visible):
**A. Title Block & Project Information:**
Project name, drawing title, sheet numbers
Scale information, revision dates
Professional stamps and signatures

**B. Area Calculations & Measurements:**
All room dimensions (length x width)
Square footage/square meter values
Total building area calculations
Coverage percentages and ratios

**C. Room Labels & Designations:**
Every room name exactly as written
Room codes or numbers
Functional designations (bedroom, bathroom, kitchen, etc.)

**D. Technical Specifications:**
Door sizes and types
Window dimensions and quantities
Wall thicknesses
Structural notes and building codes
Material specifications

### 2. Visual Description (Describe What You See):
**A. Overall Layout:**
Number of floors shown
General building shape and orientation
Relationship between different views (plan, elevation, section)

**B. Room-by-Room Description:**
Start from main entrance
Describe each room's location, size, and adjacent spaces
Note built-in features, fixtures, appliances
Identify circulation paths and connections

**C. Architectural Elements:**
Wall types and configurations
Door locations and swing directions
Window placements and orientations
Stairs, if present
Utility connections (plumbing, electrical symbols)

**D. Legend and Symbols:**
Explain any hatching patterns, line types
Describe symbols used for fixtures, appliances
Note any color coding or special markings

### 3. Data Organization & Analysis:
**A. Building Summary:**
Building type and function
Total number of rooms
Total floor area
Number of bedrooms, bathrooms, etc.

**B. Compliance & Technical Notes:**
Building codes referenced
Setback requirements
Coverage ratios
Professional certifications noted

**C. Design Assessment:**
Functional layout efficiency
Space relationships and flow
Any apparent design issues or missing information

## Extraction Guidelines:
**Read text exactly as written** - don't interpret or correct spelling
**Include all numbers** with their units (sq ft, sq m, feet, meters)
**List dimensions systematically** - room by room
**Note incomplete information** - mark anything unclear or missing
**Separate facts from interpretation** - what you see vs. what you infer
**Use consistent formatting** - bullet points for lists, tables for dimensions
**Check all corners** of the image for text or details

## Output Format:
Use clear headings, bullet points, and tables. Present numerical data in organized lists. Flag any text that's unclear or partially visible.
  1. Connect the Chat node to the Processing node.

  2. Start:

    • Connect the Processing node to the Start node.

  3. Agent

    • Select your created Agent prompt ("Building Inspector Agent").

    • Scroll down and set the State settings:

      • Document Cache: Enable Document Cache and select the Type as Retrieve Documents.

      • Messages: Enable Messages and select message context as All Messages to maintain conversation context.

    • Connect the Start node to the Agent node.

  4. End

    • This indicates the end of recipe workflow.

    • Connect the Agent node to the End node.

  5. On the right side, set the Number of state updates to a higher value such as 75.

  6. Save and Publish the recipe.

  7. By default, the V1 version is deployed once it is published.

  8. For subsequent versions, use the Actions button and select Deploy to deploy the new version. [Hint: Use Actions Button to select Deploy dropdown].

  9. Test the recipe once published. The following is an example question to test the recipe:

    1. What is the minimum ceiling height for basement?

    2. For townhouses, what fire-resistance rating is required for the wall assembly separating units?

Refer to the following video to create and test the recipe.

Step 3: Deploy Your Building Inspector Assistant

STOP: Make sure you have "published" the recipe before continuing to this step

  1. Click Action -> Export to navigate to Export Recipes page.

  2. Click Add new to create a deployment configuration.

  3. Complete the export form:

    1. Name: "Building Inspector Assistant".

    2. Description: "Agentic Building Inspector is an intelligent virtual assistant designed to help city officials, architects, and builders ensure compliance with the city of Miami's building codes. It reviews floor plans and blueprints to identify potential violations, ensuring that all construction projects meet safety and regulatory standards."

    3. Add Seed Questions:

      1. For townhouses, what fire-resistance rating is required for the wall assembly separating units?

      2. What are the five types of loads that buildings must be constructed to safely support according to R301.1?

      3. What is the minimum clearance required between exterior wall coverings and final earth grade for termite inspection purposes?

      4. A contractor is building a house in an area with a 120 mph ultimate design wind speed. What specific design standards must they follow?

  4. Add Error message as follows: “Apologies for the error, please try again”

  5. Enable positive (thumbs up) and negative (thumbs down) feedback.

  6. Users can also add custom feedback.

  7. Enable Show traces.

  8. Save the export.

  9. User can access the Copilot in two ways:

    • From the Exported Recipe

      1. Open the saved export , click the < icon on the right panel.

      2. The Visit Copilot button will appear.

      3. Click Visit Copilot to open and interact with your Copilot.

    • From the left menu

      • The Copilot will be displayed in the Copilots section of the vertical menu.

Step 4: Test Your Building Inspector Assistant

  1. Navigate to the Copilots and open your copilot "Building Inspector Assistant".

  2. Try these sample questions:

    1. For Q&A:

      1. For townhouses, what fire-resistance rating is required for the wall assembly separating units?

      2. What are the five types of loads that buildings must be constructed to safely support according to R301.1?

      3. What is the minimum clearance required between exterior wall coverings and final earth grade for termite inspection purposes?

      4. A contractor is building a house in an area with a 120 mph ultimate design wind speed. What specific design standards must they follow?

    2. For floor analyze

      1. Download the images from the path given https://app.box.com/s/di135bh4vdqhmgzniuxpb99xo07zylmc

      2. Click on upload and select the downloaded image in above step..

      3. Ask the question :

        1. Analyze the floor plan .

        2. what are potential violations in the plan against city codes?

    3. Wait for a few moments while the system processes the query. Response times may vary depending on the complexity of the question.

    4. After submitting the question, the Trace icon will appear, allowing you to view the tools invoked along with their inputs and outputs.

    5. Once the response is generated, the following elements will be visible:

      • Answer : the system’s response to the question (text or table format).

      • Citations : sources referenced in the response, so you can access the original documents.

      • Follow-up Questions : suggested related questions that allow you to continue exploring the topic.

      • Prompt Lens :to inspect the underlying prompt and response details.

      • Copy button :to copy the answer for reuse.

      • Feedback options : to rate the response with a thumbs up or thumbs down.

Refer to the following video for copilot functionality.

Last updated