Carlos Salgado commited on
Commit
1936a2d
2 Parent(s): 7e8b085 be0ac49

Merge pull request #21 from eliawaefler/metadata

Browse files
Files changed (4) hide show
  1. generate_metadata.py +43 -0
  2. schema.py +9 -119
  3. school_plumbing.txt +15 -0
  4. schulgebäudes.txt +15 -0
generate_metadata.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import openai
4
+ from dotenv import load_dotenv
5
+
6
+ from schema import Metadata, BimDiscipline
7
+
8
+ load_dotenv()
9
+
10
+ with open('school_plumbing.txt', 'r') as f:
11
+ #with open('schulgebäudes.txt', 'r') as f:
12
+ context = f.readlines()
13
+
14
+ # Create client
15
+ client = openai.OpenAI(
16
+ base_url="https://api.together.xyz/v1",
17
+ api_key=os.environ["TOGETHER_API_KEY"],
18
+ )
19
+
20
+ # Call the LLM with the JSON schema
21
+ chat_completion = client.chat.completions.create(
22
+ model="mistralai/Mixtral-8x7B-Instruct-v0.1",
23
+ response_format={"type": "json_object", "schema": Metadata.model_json_schema()},
24
+ messages=[
25
+ {
26
+ "role": "system",
27
+ "content": f"You are a helpful assistant that understands BIM documents and engineering disciplines. Your answer should be in JSON format and only include the title, a brief one-sentence summary, and the discipline the document belongs to distinguishing between {[d.value for d in BimDiscipline]} based on the given document."
28
+ },
29
+ {
30
+ "role": "user",
31
+ "content": f"Analyze the provided document, which could be in either German or English. Extract the title, summarize it briefly in one sentence, and infer the discipline. Document:\n{context}"
32
+ }
33
+ ],
34
+ )
35
+
36
+ created_user = json.loads(chat_completion.choices[0].message.content)
37
+ print(json.dumps(created_user, indent=2))
38
+
39
+ {
40
+ "title": "Plumbing System for a Typical School Building",
41
+ "summary": "This document details the plumbing system of a school building, including potable water supply, fixtures and appliances, drainage waste and vent systems, and stormwater management, adhering to ADA compliance, low flow rates, water conservation standards, and local codes and regulations.\n",
42
+ "discipline": "S - Sanit\u00e4r"
43
+ }
schema.py CHANGED
@@ -1,130 +1,20 @@
1
  import os
2
  import json
3
  from typing import List, Optional
4
- from pydantic import BaseModel, Field
5
  from enum import Enum
6
 
7
- class BimDiscipline(Enum):
8
  plumbing = 'S - Sanitär'
9
- network = 'd - Datennetz'
10
- heating = 'h - Heizung'
11
- electrical = 'e - Elektro'
12
- ventilation = 'l - Lüftung'
13
- architecture = 'a - Architektur'
14
-
15
- class KeywordChoice(str, Enum):
16
- three_dimensional_modeling = "3d modeling"
17
- four_dimensional_simulation = "4d simulation"
18
- five_dimensional_cost_estimation = "5d cost estimation"
19
- six_dimensional_lifecycle_management = "6d lifecycle management"
20
- adoption = "adoptions"
21
- agile_bim = "agile bim"
22
- artificial_intelligence = "artificial intelligence"
23
- automated_code_checking = "automated code checking"
24
- automation = "automation"
25
- big_data_analytics = "big data analytics"
26
- bim_based_estimating = "bim-based estimating"
27
- bim_execution_plan = "bim execution plan"
28
- bim_governance = "bim governance"
29
- bim_integration = "bim integration"
30
- bim_maturity = "bim maturity"
31
- bim_objects = "bim objects"
32
- bim_process = "bim process"
33
- bim_quality_assurance = "bim quality assurance"
34
- bim_requirements = "bim requirements"
35
- bim_server = "bim server"
36
- bim_standardization = "bim standardization"
37
- bim_strategy = "bim strategy"
38
- bim_tools = "bim tools"
39
- bim_training = "bim training"
40
- barriers = "barriers"
41
- benchmarking = "benchmarking"
42
- building_energy_modeling = "building energy modeling"
43
- building_life_cycle = "building life cycle"
44
- building_physics = "building physics"
45
- building_smartness = "building smartness"
46
- built_environment = "built environment"
47
- case_studies = "case studies"
48
- cloud_computing = "cloud computing"
49
- collaborative_environments = "collaborative environments"
50
- communication = "communication"
51
- computational_design = "computational design"
52
- cobie = "construction operations building information exchange"
53
- construction_scheduling = "construction scheduling"
54
- construction_site_layout = "construction site layout"
55
- context_awareness = "context awareness"
56
- contractual_issues = "contractual issues"
57
- cost_control = "cost control"
58
- critical_success_factors = "critical success factors"
59
- digital_fabrication = "digital fabrication"
60
- digital_twin = "digital twin"
61
- disaster_response = "disaster response"
62
- dispute_resolution = "dispute resolution"
63
- dynamic_scheduling = "dynamic scheduling"
64
- education = "education"
65
- electronic_tendering = "electronic tendering"
66
- empirical_research = "empirical research"
67
- energy_analysis = "energy analysis"
68
- environmental_impacts = "environmental impacts"
69
- facility_management = "facility management"
70
- fire_safety = "fire safety"
71
- gis_integration = "gis integration"
72
- green_buildings = "green buildings"
73
- health_and_safety = "health and safety"
74
- historical_preservation = "historical preservation"
75
- human_behavior = "human behavior"
76
- industrialized_construction = "industrialized construction"
77
- information_management = "information management"
78
- infrastructure_asset_management = "infrastructure asset management"
79
- interoperability = "interoperability"
80
- iot_integration = "iot integration"
81
- knowledge_sharing = "knowledge sharing"
82
- lean_construction = "lean construction"
83
- legal_frameworks = "legal frameworks"
84
- level_of_development = "level of development"
85
- level_of_detail = "level of detail"
86
- level_of_information_need = "level of information need"
87
- lifetime_costs = "lifetime costs"
88
- linked_data = "linked data"
89
- machine_learning = "machine learning"
90
- manufacturing = "manufacturing"
91
- materials_management = "materials management"
92
- mobile_applications = "mobile applications"
93
- multi_criteria_decision_making = "multi-criteria decision making"
94
- natural_language_processing = "natural language processing"
95
- networking = "networking"
96
- open_bim = "open bim"
97
- organizational_change = "organizational change"
98
- owner_involvement = "owner involvement"
99
- parametric_design = "parametric design"
100
- performance_measurement = "performance measurement"
101
- pipeline_simulation = "pipeline simulation"
102
- policy_implications = "policy implications"
103
- predictive_maintenance = "predictive maintenance"
104
- product_data_templates = "product data templates"
105
- public_procurement = "public procurement"
106
- radio_frequency_identification = "radio frequency identification"
107
- reality_capture = "reality capture"
108
- real_time_monitoring = "real-time monitoring"
109
- reliability_engineering = "reliability engineering"
110
- resilience = "resilience"
111
- return_on_investment = "return on investment"
112
- reverse_logistics = "reverse logistics"
113
- risk_assessment = "risk assessment"
114
- robotics = "robotics"
115
- maintenance_management = "maintenance management"
116
 
117
  # Define the schema for the output.
118
  class Metadata(BaseModel):
119
  title: str = Field(description='Title of the document')
120
  summary: str = Field(description='One sentence short summary of the document information')
121
- disciplines: List[str] = Field(
122
- default_factory=list,
123
- description='BIM disciplines the document belongs to',
124
- example=['S - Sanitär', 'D - Datennetz']
125
- )
126
- keywords: List[str] = Field(
127
- default_factory=list,
128
- description='List of BIM keywords associated with the document',
129
- example=['3D Modelling', 'Clash detection']
130
- )
 
1
  import os
2
  import json
3
  from typing import List, Optional
4
+ from pydantic import BaseModel, Field, conlist
5
  from enum import Enum
6
 
7
+ class BimDiscipline(str, Enum):
8
  plumbing = 'S - Sanitär'
9
+ network = 'D - Datennetz'
10
+ heating = 'H - Heizung'
11
+ electrical = 'E - Elektro'
12
+ ventilation = 'L - Lüftung'
13
+ architecture = 'A - Architektur'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  # Define the schema for the output.
16
  class Metadata(BaseModel):
17
  title: str = Field(description='Title of the document')
18
  summary: str = Field(description='One sentence short summary of the document information')
19
+ discipline: BimDiscipline
20
+
 
 
 
 
 
 
 
 
school_plumbing.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ This document describes the plumbing system for a typical school building. The system includes potable water supply, fixtures and appliances, drainage waste and vent (DWV) systems, and stormwater management.
2
+
3
+ Potable Water Supply System:
4
+ The potable water supply system consists of incoming water service from the municipal water main, backflow prevention device, water meter, pressure reducing valve, and distribution piping throughout the building to provide water to all fixtures and appliances. All materials used are lead-free and meet local codes and regulations.
5
+ Fixtures and Appliances:
6
+ Fixtures include sinks, toilets, urinals, drinking fountains, showers, eye wash stations, and laboratory equipment. All fixtures are selected based on ADA compliance, low flow rates, and water conservation standards. Appliances such as dishwashers, ice makers, and clothes washing machines are also provided with hot and cold water connections.
7
+ Drainage Waste and Vent (DWV) Systems:
8
+ The DWV system consists of sanitary and roof drains, vents, cleanouts, and traps designed to remove wastewater from fixtures and appliances while preventing sewer gases from entering the building. Materials used include PVC or cast iron pipes, fittings, and accessories.
9
+ Stormwater Management:
10
+ Stormwater management involves collecting rainwater runoff from rooftops and other impervious surfaces, conveying it through underground pipes, and disposing of it into an approved location. This may involve retention/detention ponds, swales, or other methods depending on local codes and regulations.
11
+ Maintenance and Inspection:
12
+ Regular maintenance and inspection of the plumbing system ensure its longevity and proper functioning. Routine tasks include checking for leaks, testing backflow preventers, inspecting fixtures and appliances, cleaning drains, and ensuring code compliance.
13
+ Emergency Procedures:
14
+ Emergency procedures should be established and communicated to staff members regarding responding to plumbing emergencies such as flooding, pipe bursts, or gas leaks. These procedures should include shutting off water supplies, contacting emergency responders, and notifying facilities personnel.
15
+
schulgebäudes.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Diese Beschreibung umfasst das Rohrleitungssystem eines typischen Schulgebäudes. Das System besteht aus Trinkwasserversorgungs-, Einrichtungen und Geräten, Abwassersammel-, Lüftungs- und Regenwasserbewirtschaftungssystemen.
2
+
3
+ Trinkwasserversorgungssystem:
4
+ Das Trinkwasserversorgungssystem umfasst die eingehende Wasserzufuhr von der Hauptwasserleitung des Versorgungsunternehmens, einen Rückschlagverhinderer, einen Wasserzähler, eine Druckreduziervorrichtung sowie Verteilungsrohre im Gebäude zur Bereitstellung von Wasser für alle Einrichtungen und Geräte. Alle verwendeten Materialien sind bleifrei und entsprechen lokalen Vorschriften und Bestimmungen.
5
+ Einrichtungen und Geräte:
6
+ Zu den Einrichtungen gehören Waschbecken, Toiletten, Urinale, Trinkbrunnen, Duschen, Augenduschen und Laborausrüstungen. Alle Einrichtungen werden nach den Kriterien der Barrierefreiheit, niedriger Durchflussraten und Wasser sparenden Standards ausgewählt. Zu den Geräten zählen Geschirrspülmaschinen, Eismaschinen und Kleidungswaschanlagen mit heißem und kaltem Wasseranschluss.
7
+ Sammel- und Entlüftungssystem (DWV):
8
+ Das DWV-System besteht aus Schmutzwassertonnen, Dachabläufen, Belüftungen, Reinigungsöffnungen und Fallstricken, die dazu dienen, Abwasser von Einrichtungen und Geräten zu entfernen, während gleichzeitig verhindert wird, dass schädliche Gase in das Gebäude eindringen. Die verwendeten Materialien sind PVC oder Graugußrohre, -fittinge und -zubehörteile.
9
+ Regenwasserbewirtschaftung:
10
+ Die Regenwasserbewirtschaftung sieht vor, Niederschlagswasser von Dächern und anderen wasserundurchlässigen Oberflächen aufzunehmen, durch unterirdische Rohre abzuleiten und es an einem genehmigten Ort wieder abzugeben. Dies kann Bepumpungsanlagen, Retentions-/Entlastungspoldern oder andere Methoden umfassen, je nach lokalen Vorschriften und Bestimmungen.
11
+ Wartung und Inspektion:
12
+ Routinemäßige Wartung und Inspektion des Rohrleitungssystems gewährleisten seine Lebensdauer und ordnungsgemäße Funktion. Routineaufgaben umfassen das Überprüfen auf Lecks, Testen von Rückschlagverhinderern, Inspizieren von Einrichtungen und Geräten, Reinigen von Abflüssen und Gewährleistung der Codekonformität.
13
+ Notfallmaßnahmen:
14
+ Notfallmaßnahmen sollten festgelegt und dem Personal bekannt gemacht werden, um auf Plattfälle wie Überschwemmungen, Wasserrohrbrüche oder Gaslecks zu reagieren. Diese Maßnahmen umfassen das Absperren der Wasserzuflüsse, Kontaktaufnahme mit Notdiensten, Benachrichtigung von Einrichtungspersonal und Festlegen klarer Anweisungen für die Mitarbeiter.
15
+