### Install Prerequisites Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/07-multi-language-comparison/README.md Install the necessary Python packages to run the comparison scripts. ```bash pip install pandas pyarrow matplotlib python-dotenv ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Installs the necessary Python packages for local development. Run this command in the 'examples' directory. ```bash cd examples pip install -r python/requirements.txt ``` -------------------------------- ### Run Qdrant Search Example Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/rust/02-qdrant-search/README.md Execute the search example using the default configuration or a custom Qdrant server URL. ```bash # From the examples/rust directory: cargo run -p qdrant-search # With a custom Qdrant URL: QDRANT_URL=http://my-server:6334 cargo run -p qdrant-search ``` -------------------------------- ### Install Prerequisites Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/09-filtered-search/README.md Install the necessary Python packages to run the search scripts. ```bash pip install openai qdrant-client python-dotenv tabulate ``` -------------------------------- ### Install via APT Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md Commands to add the DDC repository and install a specific language collection. ```bash # Add the DDC package repository echo "deb [trusted=yes] https://pkg.datadrivenconstruction.io stable main" \ | sudo tee /etc/apt/sources.list.d/ddc.list sudo apt update ``` ```bash # Install English construction cost database (downloads ~1 GB of vector data) sudo apt install ddc-cwicr-en # Verify Qdrant is running systemctl status qdrant curl http://localhost:6333/collections ``` ```bash sudo apt install ddc-cwicr-en ddc-cwicr-de ddc-cwicr-fr ``` -------------------------------- ### Quick Start with DDC CWICR REST API in JavaScript Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md A quick start guide for interacting with the DDC CWICR REST API using node-fetch in a Node.js environment. ```javascript // This is a placeholder for the actual code from the example. // The actual code for '02-api-quickstart' in JavaScript is not provided in the text. ``` -------------------------------- ### Setup Docker and Qdrant Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Sets up the local Qdrant instance using Docker Compose and prepares the environment. Ensure to edit the .env file with your API keys. ```bash cd examples cp .env.example .env # Edit .env with your API keys docker compose up -d # Load collections (see shell/setup-qdrant) ``` -------------------------------- ### Install Pipeline Dependencies Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/10-embedding-pipeline/README.md Install the required Python packages including OpenAI, Qdrant client, and data processing libraries. ```bash pip install openai qdrant-client pandas pyarrow python-dotenv tqdm ``` -------------------------------- ### Initialize and Import Qdrant Data Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Commands to start the Qdrant service, upload a snapshot, and verify the collection status. ```bash # Start Qdrant docker-compose up -d # Wait for Qdrant to be ready curl -s http://localhost:6333/healthz # Import snapshot (English/Toronto collection) curl -X POST "http://localhost:6333/collections/ddc_en_toronto/snapshots/upload" \ -H "Content-Type: multipart/form-data" \ -F "snapshot=@EN___DDC_CWICR/EN_TORONTO_workitems_costs_resources_EMBEDDINGS_3072_DDC_CWICR.snapshot" # Verify import curl -s "http://localhost:6333/collections/ddc_en_toronto" | python3 -m json.tool # Expected: 55,719 points # Access dashboard echo "Dashboard: http://localhost:6333/dashboard" ``` -------------------------------- ### Manage Docker Deployment Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md Commands to start the container and import a snapshot into a specific collection. ```bash # Start docker-compose up -d # Import snapshot curl -X POST "http://localhost:6333/collections/ddc_en_toronto/snapshots/upload" \ -H "Content-Type: multipart/form-data" \ -F "snapshot=@EN___DDC_CWICR/EN_TORONTO_workitems_costs_resources_EMBEDDINGS_3072_DDC_CWICR.snapshot" # Dashboard: http://localhost:6333/dashboard ``` -------------------------------- ### Install Dependencies for Natural Language Query Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/javascript/05-natural-language-query/README.md Run these commands in the parent directory to set up the required Node.js environment. ```bash cd examples/javascript npm install ``` -------------------------------- ### Install Required R Packages Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/r/02-cost-analysis/README.md Install the necessary dependencies for data processing and visualization. ```r install.packages(c("arrow", "ggplot2", "dplyr", "scales", "tidyr")) ``` -------------------------------- ### Photo-Based Cost Estimation via Web Form Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md An n8n workflow guide for building a web form that enables photo-based cost estimation using OpenAI and Qdrant. ```markdown # This is a placeholder for the actual content from the guide. # The actual content for 'Workflow 2 -- Photo Estimate' in n8n is not provided in the text. ``` -------------------------------- ### Install RAG Dependencies Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/06-rag-pipeline/README.md Installs necessary Python packages for RAG pipelines, including OpenAI, Anthropic, Qdrant client, and LangChain components. ```bash pip install openai anthropic qdrant-client python-dotenv langchain langchain-openai langchain-qdrant ``` -------------------------------- ### CLI Search Tool Usage Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md Commands for installing and using the ddc-search CLI tool for semantic and keyword queries. ```bash sudo apt install ddc-cwicr-cli ``` ```bash export OPENAI_API_KEY=sk-... ddc-search "reinforced concrete foundation 300mm" ``` ```bash ddc-search --keyword "concrete" ``` ```bash # Search a specific language collection ddc-search --collection ddc_de_berlin "Stahlbetonfundament" # List all installed collections ddc-search --list # JSON output for scripting and automation ddc-search --json "floor tiles installation" # Limit number of results ddc-search --limit 10 "steel beam HEB 300" ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/08-data-analysis/README.md Installs necessary Python packages for data analysis and visualization. 'kaleido' is optional and only required for saving Plotly charts as static images. ```bash pip install pandas pyarrow matplotlib plotly python-dotenv kaleido ``` -------------------------------- ### Multi-Modal Bot (Text + Photo + PDF) Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md An n8n workflow guide for a multi-modal bot that handles text, photo, and PDF inputs for cost estimation, integrating Telegram, OpenAI, and Qdrant. ```markdown # This is a placeholder for the actual content from the guide. # The actual content for 'Workflow 3 -- Universal Bot' in n8n is not provided in the text. ``` -------------------------------- ### Telegram Bot for Text-Based Cost Estimation Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md An n8n workflow guide for creating a Telegram bot that performs text-based cost estimation using OpenAI and Qdrant. ```markdown # This is a placeholder for the actual content from the guide. # The actual content for 'Workflow 1 -- Text Bot' in n8n is not provided in the text. ``` -------------------------------- ### CAD/BIM to Cost Estimate Pipeline Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md An n8n workflow guide detailing a 10-stage pipeline for converting CAD/BIM data to cost estimates, utilizing Revit, OpenAI, and Qdrant. ```markdown # This is a placeholder for the actual content from the guide. # The actual content for 'Workflow 4 -- CAD/BIM Pipeline' in n8n is not provided in the text. ``` -------------------------------- ### Set up Qdrant with Docker Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Instructions for setting up Qdrant and loading DDC CWICR collections using Docker. ```shell # This is a placeholder for the actual code from the example. # The actual code for 'setup-qdrant' in Shell is not provided in the text. ``` -------------------------------- ### Install Required R Packages Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/r/01-load-and-explore/README.md Install the 'arrow', 'dplyr', and 'tibble' R packages. Ensure you have R version 4.1 or higher. ```r install.packages(c("arrow", "dplyr", "tibble")) ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/09-filtered-search/README.md Set up the required API keys and instance URLs in a .env file. ```text OPENAI_API_KEY=sk-... QDRANT_URL=https://your-qdrant-instance.cloud QDRANT_API_KEY=your-qdrant-api-key ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/06-rag-pipeline/README.md Sets up environment variables for API keys and Qdrant instance URL. Ensure these are set in a .env file or exported directly. ```bash OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... QDRANT_URL=https://your-qdrant-instance.cloud QDRANT_API_KEY=your-qdrant-api-key ``` -------------------------------- ### DDC CWICR REST API Usage Examples Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Examples of using the DDC CWICR REST API with cURL and jq for data retrieval and manipulation. ```bash # Example: search for "concrete foundation" in the English/Toronto collection curl -X POST "http://localhost:6333/collections/ddc_en_toronto/points/search" \ -H "Content-Type: application/json" \ -d '{"vector": [...], "limit": 5}' ``` -------------------------------- ### GET /api/v1/languages Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md Retrieve a list of all supported languages and their respective item counts. ```APIDOC ## GET /api/v1/languages ### Description Returns all available languages with item counts. ### Method GET ### Endpoint /api/v1/languages ``` -------------------------------- ### Execute Qdrant search via CLI Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/javascript/02-api-quickstart/README.md Set the required OpenAI API key and execute the search script using Node.js. ```bash export OPENAI_API_KEY="sk-..." node search_api.mjs ``` -------------------------------- ### GET /api/v1/stats Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md Retrieve database statistics including item counts, categories, and metadata. ```APIDOC ## GET /api/v1/stats ### Description Returns item counts, categories, languages, and metadata. ### Method GET ### Endpoint /api/v1/stats ``` -------------------------------- ### Execute Basic Search Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/javascript/03-semantic-search-qdrant/README.md Set the OpenAI API key and run the basic search script. ```bash export OPENAI_API_KEY="sk-..." node basic_search.mjs ``` -------------------------------- ### Run Basic RAG Pipeline Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/06-rag-pipeline/README.md Executes the basic RAG pipeline using the Anthropic (Claude) SDK for LLM generation and Qdrant for retrieval. Specify your query using the --query argument. ```bash python rag_basic.py --query "What is the cost of reinforced concrete foundation work?" ``` -------------------------------- ### Run Photo Cost Estimator Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/04-cost-estimation-photo/README.md Execute the cost estimation script with a photo file path. Optionally specify a Qdrant collection and the number of top results to consider. ```bash python estimate_from_photo.py /path/to/construction_photo.jpg ``` ```bash python estimate_from_photo.py photo.png --collection ddc_de_berlin --top 3 ``` -------------------------------- ### Cost Estimation from Photos via Vision AI in Python Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Estimate costs from construction site photos using vision AI with qdrant-client and openai. ```python # This is a placeholder for the actual code from the example. # The actual code for '04-cost-estimation-photo' in Python is not provided in the text. ``` -------------------------------- ### Input CSV Format Example Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/05-boq-generation/README.md Define the structure for the input CSV file, including description, quantity, and unit. ```csv description,quantity,unit concrete foundation slab,120,m² brick wall construction,85,m² ``` -------------------------------- ### Deploy Qdrant with Docker Compose Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Configuration for running Qdrant locally with persistent storage and gRPC support. ```yaml # docker-compose.yml version: "3.8" services: qdrant: image: qdrant/qdrant:latest ports: - "6333:6333" - "6334:6334" volumes: - qdrant_data:/qdrant/storage environment: - QDRANT__SERVICE__GRPC_PORT=6334 volumes: qdrant_data: ``` -------------------------------- ### Execute Cost Visualization Script Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/r/02-cost-analysis/README.md Run the visualization script from the command line, optionally specifying a custom Parquet file path. ```bash Rscript cost_visualization.R # or with a custom path: Rscript cost_visualization.R /path/to/your/file.parquet ``` -------------------------------- ### Load Parquet Data with Pandas Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/1_AI_INSTRUCTIONS/CLAUDE.md Use this snippet to load the DDC CWICR database from a Parquet file into a Pandas DataFrame for exploration and analysis. Ensure Pandas is installed. ```python import pandas as pd # Load the database df = pd.read_parquet("DDC_CWICR_EN.parquet") # Explore structure print(f"Rows: {len(df)}, Columns: {len(df.columns)}") print(df.columns.tolist()) ``` -------------------------------- ### Analyze Construction Photo for Cost Estimation Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Uses OpenAI's GPT-4o Vision to analyze a construction photo, identify elements, estimate quantities, and then searches Qdrant for matching rates. Requires OPENAI_API_KEY and a running Qdrant instance. ```python import os import json import base64 from pathlib import Path from openai import OpenAI from qdrant_client import QdrantClient openai_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) qdrant = QdrantClient(url="http://localhost:6333") VISION_PROMPT = """Analyze this construction photo. Identify all visible construction elements. For each element, provide: description (for cost lookup), quantity (estimated), unit (m², m³, pcs, etc.) Return ONLY valid JSON as a list. Example: [{"description": "reinforced concrete column", "quantity": 4, "unit": "pcs"}]""" def analyze_photo(image_path: str) -> list[dict]: with open(image_path, "rb") as f: b64_image = base64.b64encode(f.read()).decode("utf-8") ext = Path(image_path).suffix.lower() mime = {"jpg": "image/jpeg", "jpeg": "image/jpeg", "png": "image/png"}.get(ext[1:], "image/jpeg") response = openai_client.chat.completions.create( model="gpt-4o", messages=[{ "role": "user", "content": [ {"type": "text", "text": VISION_PROMPT}, {"type": "image_url", "image_url": {"url": f"data:{mime};base64,{b64_image}"}} ] }], temperature=0.2, max_tokens=2048 ) return json.loads(response.choices[0].message.content.strip("```json").strip("```")) def get_embedding(text: str) -> list[float]: response = openai_client.embeddings.create(model="text-embedding-3-large", input=text) return response.data[0].embedding def search_rate(description: str) -> dict | None: results = qdrant.search( collection_name="ddc_en_toronto", query_vector=get_embedding(description), limit=1 ) return results[0].payload if results else None ``` -------------------------------- ### Compare Pricing Across Regions in Python Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Compare construction item pricing across different regions and languages using qdrant-client. ```python # This is a placeholder for the actual code from the example. # The actual code for '07-multi-language-comparison' in Python is not provided in the text. ``` -------------------------------- ### Search Construction Items using Python Requests Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md This Python script uses the 'requests' library to search for construction items and print their names and pricing. Ensure you have the 'requests' library installed. ```python import requests response = requests.get("https://buildcalculator.io/api/v1/search", params={"q": "brick masonry walls", "lang": "en", "top": 5}) data = response.json() for item in data["results"]: print(f"{item['name']} — {item['pricing']['total_per_unit']} EUR/{item['unit']}") ``` -------------------------------- ### Deploy Qdrant with Docker Compose Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md Configuration for running the Qdrant vector database container with persistent storage and snapshot support. ```yaml # docker-compose.yml services: qdrant: image: qdrant/qdrant:latest container_name: ddc-cwicr-qdrant ports: - "6333:6333" - "6334:6334" volumes: - qdrant_storage:/qdrant/storage - ./snapshots:/qdrant/snapshots environment: - QDRANT__LOG_LEVEL=INFO restart: unless-stopped volumes: qdrant_storage: ``` -------------------------------- ### Generate Bill of Quantities in Python Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Generate a Bill of Quantities (BOQ) from a project description using qdrant-client and openai. ```python # This is a placeholder for the actual code from the example. # The actual code for '05-boq-generation' in Python is not provided in the text. ``` -------------------------------- ### Run BOQ Generation Script Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/05-boq-generation/README.md Execute the main BOQ generation script with different input and output configurations. ```bash python generate_boq.py sample_input.csv ``` ```bash python generate_boq.py my_items.csv --output my_boq.xlsx ``` ```bash python generate_boq.py sample_input.csv --collection ddc_de_berlin ``` -------------------------------- ### Filtered Semantic Search with Cost Range and Department Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Combine vector similarity search with payload filters in Qdrant to refine results by department and cost range. This example demonstrates building a filter with must conditions for specific criteria. ```python import os from openai import OpenAI from qdrant_client import QdrantClient from qdrant_client.models import Filter, FieldCondition, MatchValue, Range openai_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) qdrant = QdrantClient(url="http://localhost:6333") def get_embedding(text: str) -> list[float]: response = openai_client.embeddings.create( model="text-embedding-3-large", input=text ) return response.data[0].embedding # Build filter: department + cost range query_filter = Filter(must=[ FieldCondition( key="department_name", match=MatchValue(value="Concrete and Reinforced Concrete") ), FieldCondition( key="total_cost_per_position", range=Range(gte=100, lte=5000) # EUR 100-5000 ) ]) ``` -------------------------------- ### Search Construction Items with BuildCalculator.io JavaScript Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Fetch construction item data from the BuildCalculator.io REST API using JavaScript's fetch API. This example demonstrates iterating through results to log item names and pricing information to the console. ```javascript const res = await fetch( "https://buildcalculator.io/api/v1/search?q=HVAC+ducting&lang=en&top=3" ); const data = await res.json(); data.results.forEach(item => { console.log(`${item.name}: ${item.pricing.total_per_unit} EUR/${item.unit}`); }); ``` -------------------------------- ### Execute RAG Pipeline for Construction Cost Query Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt This Python script demonstrates a Retrieval-Augmented Generation (RAG) pipeline to answer construction cost questions. It embeds a query, searches Qdrant for relevant context, and then uses Claude to generate an answer based on the context. ```python question = "What is the cost of reinforced concrete foundation work per cubic metre?" print(f"Question: {question}\n") print("[1/3] Embedding query...") query_vector = embed_query(question) print("[2/3] Searching Qdrant...") results = search_qdrant(query_vector, top_k=10) context = format_context(results) print("[3/3] Generating answer with Claude...") answer = ask_claude(question, context) print(f"\n{'='*60}\nANSWER\n{'='*60}\n{answer}") ``` -------------------------------- ### Search Construction Items with BuildCalculator.io Python Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Query the BuildCalculator.io REST API for construction costs using Python's requests library. This example shows how to parse the JSON response to display item names, units, and pricing details. ```python import requests # Search API response = requests.get("https://buildcalculator.io/api/v1/search", params={"q": "brick masonry walls", "lang": "en", "top": 5}) data = response.json() for item in data["results"]: print(f"{item['name']} — {item['pricing']['total_per_unit']} EUR/{item['unit']}") print(f" Labor: {item['pricing']['labor_per_unit']} EUR") print(f" Material: {item['pricing']['material_per_unit']} EUR") print(f" Equipment: {item['pricing']['equipment_per_unit']} EUR") ``` -------------------------------- ### Decompose Project Description for Cost Estimation Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Uses OpenAI's GPT-4o model to break down a project description into searchable work items with quantities and units. Requires OPENAI_API_KEY and a running Qdrant instance. ```python import os import json from openai import OpenAI from qdrant_client import QdrantClient openai_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) qdrant = QdrantClient(url="http://localhost:6333") DECOMPOSE_PROMPT = """You are a construction cost estimator. Decompose this project into work items. For each, provide: description (for database search), quantity (number), unit (m², m³, pcs, etc.) Return ONLY valid JSON as a list. Example: [{"description": "ceramic floor tiling", "quantity": 50, "unit": "m²"}]" Project: {description}""" def decompose_project(description: str) -> list[dict]: response = openai_client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": DECOMPOSE_PROMPT.format(description=description)}], temperature=0.2 ) return json.loads(response.choices[0].message.content.strip("```json").strip("```")) def get_embedding(text: str) -> list[float]: response = openai_client.embeddings.create(model="text-embedding-3-large", input=text) return response.data[0].embedding def search_rate(description: str) -> dict | None: results = qdrant.search( collection_name="ddc_en_toronto", query_vector=get_embedding(description), limit=1 ) return results[0].payload if results else None # Estimate a bathroom renovation project = "Complete bathroom renovation 8m²: remove old tiles, waterproofing, new ceramic tiles on floor and walls, install toilet, sink, and shower" work_items = decompose_project(project) total_cost = 0.0 print(f"Project: {project}\n") print(f"{'#':<3} {'Description':<40} {'Qty':<8} {'Unit':<6} {'Rate':>10} {'Amount':>12}") print("-" * 85) for i, item in enumerate(work_items, 1): match = search_rate(item["description"]) unit_cost = float(match.get("total_cost_per_position", 0)) if match else 0 amount = unit_cost * item["quantity"] total_cost += amount name = match.get("rate_original_name", item["description"])[:40] if match else item["description"][:40] print(f"{i:<3} {name:<40} {item['quantity']:<8} {item['unit']:<6} {unit_cost:>10,.2f} {amount:>12,.2f}") print("-" * 85) print(f"{'TOTAL':>71} {total_cost:>12,.2f} EUR") ``` -------------------------------- ### RAG Pipeline with Claude and Qdrant Source: https://context7.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/llms.txt Builds a Retrieval-Augmented Generation (RAG) pipeline using OpenAI for embeddings, Qdrant for vector search, and Anthropic's Claude for generating grounded answers. Requires API keys for OpenAI and Anthropic, and a running Qdrant instance. ```python import os from openai import OpenAI from anthropic import Anthropic from qdrant_client import QdrantClient openai_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY")) anthropic_client = Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY")) qdrant = QdrantClient(url="http://localhost:6333") def embed_query(text: str) -> list[float]: response = openai_client.embeddings.create( model="text-embedding-3-large", input=text ) return response.data[0].embedding def search_qdrant(query_vector: list[float], top_k: int = 10) -> list[dict]: results = qdrant.query_points( collection_name="ddc_en_toronto", query=query_vector, limit=top_k, with_payload=True ) return [dict(p.payload) | {"_score": p.score} for p in results.points] def format_context(items: list[dict]) -> str: lines = [] for i, item in enumerate(items, 1): parts = [f"[{i}]"] for key in ("rate_code", "rate_final_name", "rate_unit", "total_cost_per_position", "department_name", "resource_name", "labor_hours_construction_workers"): if (val := item.get(key)) is not None: parts.append(f"{key}: {val}") lines.append(" | ".join(parts)) return "\n".join(lines) def ask_claude(question: str, context: str) -> str: system = """You are a construction cost estimation assistant. Answer questions using ONLY the CWICR data provided. Cite rate codes when referencing items. Present costs in EUR unless asked otherwise.""" response = anthropic_client.messages.create( model="claude-sonnet-4-20250514", max_tokens=2048, system=system, messages=[{"role": "user", "content": f"### Data\n{context}\n\n### Question\n{question}"}] ) return response.content[0].text ``` -------------------------------- ### Execute Natural Language Query Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/javascript/05-natural-language-query/README.md Set the required OpenAI API key and run the query script. ```bash export OPENAI_API_KEY="sk-..." node nl_query.mjs ``` -------------------------------- ### Estimate Costs from Text Description Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/python/03-cost-estimation-text/README.md Execute the script with a natural language description of construction work to generate a cost estimate. You can specify the LLM provider and the Qdrant collection if needed. ```bash python estimate_from_text.py "renovate a 50m² bathroom with new tiles and plumbing" ``` ```bash python estimate_from_text.py "build a 200m² concrete foundation slab" --provider openai ``` ```bash python estimate_from_text.py "install electrical wiring in a 3-bedroom apartment" --collection ddc_de_berlin ``` -------------------------------- ### Full RAG Pipeline for Cost Q&A in Python Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Implement a full Retrieval-Augmented Generation (RAG) pipeline for cost-related question answering using qdrant-client and openai. ```python # This is a placeholder for the actual code from the example. # The actual code for '06-rag-pipeline' in Python is not provided in the text. ``` -------------------------------- ### Load Qdrant Snapshot Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/1_AI_INSTRUCTIONS/ANTIGRAVITY.md Reference for the location of the CWICR snapshot file used for loading data into Qdrant. ```bash # Snapshot is located in the repository: # EN___DDC_CWICR/EN_TORONTO_workitems_costs_resources_EMBEDDINGS_3072_DDC_CWICR.snapshot ``` -------------------------------- ### Initialize DDC CWICR with Claude Code Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/README.md Commands to clone the repository and launch the Claude Code assistant for natural language interaction. ```bash # Clone the repository git clone https://github.com/datadrivenconstruction/OpenConstructionEstimate-DDC-CWICR.git # Open with Claude Code cd OpenConstructionEstimate-DDC-CWICR claude ``` -------------------------------- ### Natural Language Queries Against Cost Data in JavaScript Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Execute natural language queries against construction cost data from a JavaScript environment using openai and @qdrant/js-client-rest. ```javascript // This is a placeholder for the actual code from the example. // The actual code for '05-natural-language-query' in JavaScript is not provided in the text. ``` -------------------------------- ### Text-Based Cost Estimation in Node.js Source: https://github.com/datadrivenconstruction/openconstructionestimate-ddc-cwicr/blob/main/0_Workflow and Pipelines CWICR/README.md Perform text-based construction cost estimation in a Node.js environment using openai and @qdrant/js-client-rest. ```javascript // This is a placeholder for the actual code from the example. // The actual code for '04-cost-estimation-text' in JavaScript is not provided in the text. ```