Update app.py
Browse files
app.py
CHANGED
@@ -135,14 +135,15 @@ custom_css = """
|
|
135 |
.container { max-width: 1000px; margin: auto; padding-top: 1.5rem; }
|
136 |
.header { text-align: center; margin-bottom: 2rem; }
|
137 |
.header h1 { color: #2c3e50; font-size: 2.5rem; }
|
138 |
-
.subheader { color: #34495e; font-size: 1.2rem; margin-bottom: 2rem; }
|
139 |
.image-container { border: 2px dashed #3498db; border-radius: 10px; padding: 1rem; text-align: center; }
|
140 |
.analyze-button { background-color: #2ecc71 !important; color: white !important; }
|
141 |
.clear-button { background-color: #e74c3c !important; color: white !important; width: 100px !important; }
|
142 |
.chatbot { border: 1px solid #bdc3c7; border-radius: 10px; padding: 1rem; height: 400px; overflow-y: auto; }
|
143 |
.chat-input { border: 1px solid #bdc3c7; border-radius: 5px; padding: 0.5rem; }
|
144 |
.groq-badge { position: fixed; bottom: 10px; right: 10px; background-color: #f39c12; color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold; }
|
145 |
-
.
|
|
|
146 |
.input-row > div:first-child { flex-grow: 1; margin-right: 10px; }
|
147 |
"""
|
148 |
|
@@ -164,16 +165,15 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
|
|
164 |
image_input = gr.Image(type="pil", label="Upload Construction Site Image", elem_classes="image-container")
|
165 |
analyze_button = gr.Button("🔍 Analyze Safety Hazards", elem_classes="analyze-button")
|
166 |
with gr.Column(scale=2):
|
167 |
-
|
168 |
-
|
169 |
-
with gr.
|
170 |
msg = gr.Textbox(
|
171 |
label="Ask about safety measures or regulations",
|
172 |
placeholder="E.g., 'What OSHA guidelines apply to this hazard?'",
|
173 |
show_label=False,
|
174 |
elem_classes="chat-input"
|
175 |
)
|
176 |
-
with gr.Column(scale=1):
|
177 |
clear = gr.Button("🗑️ Clear", elem_classes="clear-button")
|
178 |
|
179 |
def update_chat(history, new_message):
|
|
|
135 |
.container { max-width: 1000px; margin: auto; padding-top: 1.5rem; }
|
136 |
.header { text-align: center; margin-bottom: 2rem; }
|
137 |
.header h1 { color: #2c3e50; font-size: 2.5rem; }
|
138 |
+
.subheader { color: #34495e; font-size: 1.2rem; margin-bottom: 2rem; text-align: center; }
|
139 |
.image-container { border: 2px dashed #3498db; border-radius: 10px; padding: 1rem; text-align: center; }
|
140 |
.analyze-button { background-color: #2ecc71 !important; color: white !important; }
|
141 |
.clear-button { background-color: #e74c3c !important; color: white !important; width: 100px !important; }
|
142 |
.chatbot { border: 1px solid #bdc3c7; border-radius: 10px; padding: 1rem; height: 400px; overflow-y: auto; }
|
143 |
.chat-input { border: 1px solid #bdc3c7; border-radius: 5px; padding: 0.5rem; }
|
144 |
.groq-badge { position: fixed; bottom: 10px; right: 10px; background-color: #f39c12; color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold; }
|
145 |
+
.chat-container { display: flex; flex-direction: column; }
|
146 |
+
.input-row { display: flex; align-items: center; margin-top: 10px; }
|
147 |
.input-row > div:first-child { flex-grow: 1; margin-right: 10px; }
|
148 |
"""
|
149 |
|
|
|
165 |
image_input = gr.Image(type="pil", label="Upload Construction Site Image", elem_classes="image-container")
|
166 |
analyze_button = gr.Button("🔍 Analyze Safety Hazards", elem_classes="analyze-button")
|
167 |
with gr.Column(scale=2):
|
168 |
+
with gr.Group(elem_classes="chat-container"):
|
169 |
+
chatbot = gr.Chatbot(label="Safety Analysis Results and Expert Chat", elem_classes="chatbot")
|
170 |
+
with gr.Row(elem_classes="input-row"):
|
171 |
msg = gr.Textbox(
|
172 |
label="Ask about safety measures or regulations",
|
173 |
placeholder="E.g., 'What OSHA guidelines apply to this hazard?'",
|
174 |
show_label=False,
|
175 |
elem_classes="chat-input"
|
176 |
)
|
|
|
177 |
clear = gr.Button("🗑️ Clear", elem_classes="clear-button")
|
178 |
|
179 |
def update_chat(history, new_message):
|