Update app.py
Browse files
app.py
CHANGED
@@ -46,14 +46,12 @@ class RAGSystem:
|
|
46 |
@lru_cache(maxsize=1) # Cache the knowledge base
|
47 |
def load_knowledge_base() -> List[Dict]:
|
48 |
"""Load and preprocess knowledge base"""
|
49 |
-
# Your existing knowledge base code...
|
50 |
kb = {
|
51 |
"spalling": [
|
52 |
{
|
53 |
"severity": "Critical",
|
54 |
"description": "Severe concrete spalling with exposed reinforcement",
|
55 |
"repair_method": "Remove deteriorated concrete, clean reinforcement",
|
56 |
-
"estimated_cost": "Very High ($15,000+)",
|
57 |
"immediate_action": "Evacuate area, install support",
|
58 |
"prevention": "Regular inspections, waterproofing"
|
59 |
}
|
@@ -63,7 +61,6 @@ class RAGSystem:
|
|
63 |
"severity": "High",
|
64 |
"description": "Active structural cracks >5mm width",
|
65 |
"repair_method": "Structural analysis, epoxy injection",
|
66 |
-
"estimated_cost": "High ($10,000-$20,000)",
|
67 |
"immediate_action": "Install crack monitors",
|
68 |
"prevention": "Regular monitoring, load management"
|
69 |
}
|
@@ -73,13 +70,75 @@ class RAGSystem:
|
|
73 |
"severity": "Medium",
|
74 |
"description": "Surface scaling and deterioration",
|
75 |
"repair_method": "Surface preparation, patch repair",
|
76 |
-
"estimated_cost": "Medium ($5,000-$10,000)",
|
77 |
"immediate_action": "Document extent, plan repairs",
|
78 |
"prevention": "Surface sealers, proper drainage"
|
79 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
]
|
81 |
}
|
82 |
-
|
83 |
documents = []
|
84 |
for category, items in kb.items():
|
85 |
for item in items:
|
@@ -87,7 +146,7 @@ class RAGSystem:
|
|
87 |
for key, value in item.items():
|
88 |
doc_text += f"{key}: {value}\n"
|
89 |
documents.append({"text": doc_text, "metadata": {"category": category}})
|
90 |
-
|
91 |
return documents
|
92 |
|
93 |
def create_vector_store(self):
|
|
|
46 |
@lru_cache(maxsize=1) # Cache the knowledge base
|
47 |
def load_knowledge_base() -> List[Dict]:
|
48 |
"""Load and preprocess knowledge base"""
|
|
|
49 |
kb = {
|
50 |
"spalling": [
|
51 |
{
|
52 |
"severity": "Critical",
|
53 |
"description": "Severe concrete spalling with exposed reinforcement",
|
54 |
"repair_method": "Remove deteriorated concrete, clean reinforcement",
|
|
|
55 |
"immediate_action": "Evacuate area, install support",
|
56 |
"prevention": "Regular inspections, waterproofing"
|
57 |
}
|
|
|
61 |
"severity": "High",
|
62 |
"description": "Active structural cracks >5mm width",
|
63 |
"repair_method": "Structural analysis, epoxy injection",
|
|
|
64 |
"immediate_action": "Install crack monitors",
|
65 |
"prevention": "Regular monitoring, load management"
|
66 |
}
|
|
|
70 |
"severity": "Medium",
|
71 |
"description": "Surface scaling and deterioration",
|
72 |
"repair_method": "Surface preparation, patch repair",
|
|
|
73 |
"immediate_action": "Document extent, plan repairs",
|
74 |
"prevention": "Surface sealers, proper drainage"
|
75 |
}
|
76 |
+
],
|
77 |
+
"corrosion": [
|
78 |
+
{
|
79 |
+
"severity": "High",
|
80 |
+
"description": "Corrosion of reinforcement leading to cracks",
|
81 |
+
"repair_method": "Remove rust, apply inhibitors",
|
82 |
+
"immediate_action": "Isolate affected area",
|
83 |
+
"prevention": "Anti-corrosion coatings, proper drainage"
|
84 |
+
}
|
85 |
+
],
|
86 |
+
"efflorescence": [
|
87 |
+
{
|
88 |
+
"severity": "Low",
|
89 |
+
"description": "White powder deposits on concrete surfaces",
|
90 |
+
"repair_method": "Surface cleaning, sealant application",
|
91 |
+
"immediate_action": "Identify moisture source",
|
92 |
+
"prevention": "Improve waterproofing, reduce moisture ingress"
|
93 |
+
}
|
94 |
+
],
|
95 |
+
"delamination": [
|
96 |
+
{
|
97 |
+
"severity": "Medium",
|
98 |
+
"description": "Separation of layers in concrete",
|
99 |
+
"repair_method": "Resurface or replace delaminated sections",
|
100 |
+
"immediate_action": "Inspect bonding layers",
|
101 |
+
"prevention": "Proper curing and bonding agents"
|
102 |
+
}
|
103 |
+
],
|
104 |
+
"honeycombing": [
|
105 |
+
{
|
106 |
+
"severity": "Medium",
|
107 |
+
"description": "Voids in concrete caused by improper compaction",
|
108 |
+
"repair_method": "Grout injection, patch repair",
|
109 |
+
"immediate_action": "Assess structural impact",
|
110 |
+
"prevention": "Proper vibration during pouring"
|
111 |
+
}
|
112 |
+
],
|
113 |
+
"water_leakage": [
|
114 |
+
{
|
115 |
+
"severity": "High",
|
116 |
+
"description": "Water ingress through cracks or joints",
|
117 |
+
"repair_method": "Injection grouting, waterproofing membranes",
|
118 |
+
"immediate_action": "Stop water flow, apply sealants",
|
119 |
+
"prevention": "Drainage systems, joint sealing"
|
120 |
+
}
|
121 |
+
],
|
122 |
+
"settlement_cracks": [
|
123 |
+
{
|
124 |
+
"severity": "High",
|
125 |
+
"description": "Cracks due to uneven foundation settlement",
|
126 |
+
"repair_method": "Foundation underpinning, grouting",
|
127 |
+
"immediate_action": "Monitor movement, stabilize foundation",
|
128 |
+
"prevention": "Soil compaction, proper foundation design"
|
129 |
+
}
|
130 |
+
],
|
131 |
+
"shrinkage_cracks": [
|
132 |
+
{
|
133 |
+
"severity": "Low",
|
134 |
+
"description": "Minor cracks caused by shrinkage during curing",
|
135 |
+
"repair_method": "Sealant application, surface repairs",
|
136 |
+
"immediate_action": "Monitor cracks",
|
137 |
+
"prevention": "Proper curing and moisture control"
|
138 |
+
}
|
139 |
]
|
140 |
}
|
141 |
+
|
142 |
documents = []
|
143 |
for category, items in kb.items():
|
144 |
for item in items:
|
|
|
146 |
for key, value in item.items():
|
147 |
doc_text += f"{key}: {value}\n"
|
148 |
documents.append({"text": doc_text, "metadata": {"category": category}})
|
149 |
+
|
150 |
return documents
|
151 |
|
152 |
def create_vector_store(self):
|