Fix calendar and numpy imports in code generation
Browse files- Add calendar and numpy imports to code template
- Include these modules in execution environment globals
- Add numpy to requirements.txt
- Improve code styling with gradients and better visual design
- Replace basic feedback with 4-point rating system (Excellent/Good/Okay/Poor)
π€ Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
app.py
CHANGED
@@ -230,7 +230,7 @@ st.markdown("""
|
|
230 |
color: #475569;
|
231 |
border: 1px solid #e2e8f0;
|
232 |
padding: 0.375rem 0.75rem;
|
233 |
-
font-size: 0.
|
234 |
font-weight: normal;
|
235 |
text-align: left;
|
236 |
white-space: normal;
|
@@ -258,45 +258,57 @@ st.markdown("""
|
|
258 |
/* Code container styling */
|
259 |
.code-container {
|
260 |
margin: 1rem 0;
|
261 |
-
border: 1px solid #
|
262 |
-
border-radius:
|
263 |
-
background:
|
|
|
264 |
}
|
265 |
|
266 |
.code-header {
|
267 |
display: flex;
|
268 |
justify-content: space-between;
|
269 |
align-items: center;
|
270 |
-
padding: 0.
|
271 |
-
background: #f1f5f9;
|
272 |
border-bottom: 1px solid #e2e8f0;
|
273 |
cursor: pointer;
|
274 |
-
transition:
|
|
|
275 |
}
|
276 |
|
277 |
.code-header:hover {
|
278 |
-
background: #e2e8f0;
|
279 |
}
|
280 |
|
281 |
.code-title {
|
282 |
-
font-size: 0.
|
283 |
-
font-weight:
|
284 |
-
color: #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
}
|
286 |
|
287 |
.toggle-text {
|
288 |
font-size: 0.75rem;
|
289 |
-
color: #
|
|
|
290 |
}
|
291 |
|
292 |
.code-block {
|
293 |
-
background: #1e293b;
|
294 |
color: #e2e8f0;
|
295 |
-
padding:
|
296 |
-
font-family: 'Monaco', 'Menlo', monospace;
|
297 |
font-size: 0.875rem;
|
298 |
overflow-x: auto;
|
299 |
-
line-height: 1.
|
|
|
300 |
}
|
301 |
|
302 |
.answer-container {
|
@@ -665,25 +677,6 @@ if not st.session_state.responses:
|
|
665 |
</div>
|
666 |
""", unsafe_allow_html=True)
|
667 |
|
668 |
-
# Workflow steps section (like in mockup)
|
669 |
-
st.markdown("""
|
670 |
-
<div style='background: #f8fafc; border-bottom: 1px solid #e2e8f0; padding: 1rem 2rem; display: flex; gap: 1rem; margin-bottom: 1rem;'>
|
671 |
-
<div style='display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 500; background: #dcfce7; color: #166534;'>
|
672 |
-
<div style='width: 20px; height: 20px; border-radius: 50%; background: #22c55e; color: white; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600;'>1</div>
|
673 |
-
<span>Natural Language Query</span>
|
674 |
-
</div>
|
675 |
-
<div style='margin: 0 1rem; color: #9ca3af;'>β</div>
|
676 |
-
<div style='display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 500; background: #dcfce7; color: #166534;'>
|
677 |
-
<div style='width: 20px; height: 20px; border-radius: 50%; background: #22c55e; color: white; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600;'>2</div>
|
678 |
-
<span>Code Generation</span>
|
679 |
-
</div>
|
680 |
-
<div style='margin: 0 1rem; color: #9ca3af;'>β</div>
|
681 |
-
<div style='display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 6px; font-size: 0.875rem; font-weight: 500; background: #dbeafe; color: #1d4ed8;'>
|
682 |
-
<div style='width: 20px; height: 20px; border-radius: 50%; background: #3b82f6; color: white; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600;'>3</div>
|
683 |
-
<span>Visualization</span>
|
684 |
-
</div>
|
685 |
-
</div>
|
686 |
-
""", unsafe_allow_html=True)
|
687 |
|
688 |
|
689 |
def show_custom_response(response):
|
@@ -797,16 +790,28 @@ with chat_container:
|
|
797 |
else:
|
798 |
# Beautiful feedback section
|
799 |
st.markdown("---")
|
800 |
-
st.markdown("**
|
801 |
|
802 |
-
|
|
|
803 |
with col1:
|
804 |
-
|
805 |
with col2:
|
806 |
-
|
|
|
|
|
|
|
|
|
807 |
|
808 |
-
if
|
809 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
810 |
comments = st.text_area(
|
811 |
"Tell us more (optional):",
|
812 |
key=f"{feedback_key}_comments",
|
|
|
230 |
color: #475569;
|
231 |
border: 1px solid #e2e8f0;
|
232 |
padding: 0.375rem 0.75rem;
|
233 |
+
font-size: 0.65rem;
|
234 |
font-weight: normal;
|
235 |
text-align: left;
|
236 |
white-space: normal;
|
|
|
258 |
/* Code container styling */
|
259 |
.code-container {
|
260 |
margin: 1rem 0;
|
261 |
+
border: 1px solid #d1d5db;
|
262 |
+
border-radius: 12px;
|
263 |
+
background: white;
|
264 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
265 |
}
|
266 |
|
267 |
.code-header {
|
268 |
display: flex;
|
269 |
justify-content: space-between;
|
270 |
align-items: center;
|
271 |
+
padding: 0.875rem 1.25rem;
|
272 |
+
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
273 |
border-bottom: 1px solid #e2e8f0;
|
274 |
cursor: pointer;
|
275 |
+
transition: all 0.2s ease;
|
276 |
+
border-radius: 12px 12px 0 0;
|
277 |
}
|
278 |
|
279 |
.code-header:hover {
|
280 |
+
background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
|
281 |
}
|
282 |
|
283 |
.code-title {
|
284 |
+
font-size: 0.9rem;
|
285 |
+
font-weight: 600;
|
286 |
+
color: #1e293b;
|
287 |
+
display: flex;
|
288 |
+
align-items: center;
|
289 |
+
gap: 0.5rem;
|
290 |
+
}
|
291 |
+
|
292 |
+
.code-title:before {
|
293 |
+
content: "β‘";
|
294 |
+
font-size: 0.8rem;
|
295 |
}
|
296 |
|
297 |
.toggle-text {
|
298 |
font-size: 0.75rem;
|
299 |
+
color: #64748b;
|
300 |
+
font-weight: 500;
|
301 |
}
|
302 |
|
303 |
.code-block {
|
304 |
+
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
|
305 |
color: #e2e8f0;
|
306 |
+
padding: 1.5rem;
|
307 |
+
font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
|
308 |
font-size: 0.875rem;
|
309 |
overflow-x: auto;
|
310 |
+
line-height: 1.6;
|
311 |
+
border-radius: 0 0 12px 12px;
|
312 |
}
|
313 |
|
314 |
.answer-container {
|
|
|
677 |
</div>
|
678 |
""", unsafe_allow_html=True)
|
679 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
|
681 |
|
682 |
def show_custom_response(response):
|
|
|
790 |
else:
|
791 |
# Beautiful feedback section
|
792 |
st.markdown("---")
|
793 |
+
st.markdown("**Rate this response:**")
|
794 |
|
795 |
+
# More detailed feedback options
|
796 |
+
col1, col2, col3, col4 = st.columns(4)
|
797 |
with col1:
|
798 |
+
excellent = st.button("π― Excellent", key=f"{feedback_key}_excellent", use_container_width=True)
|
799 |
with col2:
|
800 |
+
good = st.button("β
Good", key=f"{feedback_key}_good", use_container_width=True)
|
801 |
+
with col3:
|
802 |
+
okay = st.button("β οΈ Okay", key=f"{feedback_key}_okay", use_container_width=True)
|
803 |
+
with col4:
|
804 |
+
poor = st.button("β Poor", key=f"{feedback_key}_poor", use_container_width=True)
|
805 |
|
806 |
+
if excellent or good or okay or poor:
|
807 |
+
if excellent:
|
808 |
+
thumbs = "π― Excellent"
|
809 |
+
elif good:
|
810 |
+
thumbs = "β
Good"
|
811 |
+
elif okay:
|
812 |
+
thumbs = "β οΈ Okay"
|
813 |
+
else:
|
814 |
+
thumbs = "β Poor"
|
815 |
comments = st.text_area(
|
816 |
"Tell us more (optional):",
|
817 |
key=f"{feedback_key}_comments",
|
src.py
CHANGED
@@ -244,7 +244,7 @@ def ask_question(model_name, question):
|
|
244 |
# Professional matplotlib styling
|
245 |
parameters = {
|
246 |
"font.size": 11,
|
247 |
-
"figure.dpi":
|
248 |
"figure.facecolor": "white",
|
249 |
"axes.facecolor": "white",
|
250 |
"axes.edgecolor": "#e2e8f0",
|
@@ -269,8 +269,31 @@ def ask_question(model_name, question):
|
|
269 |
import pandas as pd
|
270 |
import matplotlib.pyplot as plt
|
271 |
import uuid
|
|
|
|
|
272 |
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
|
275 |
df = pd.read_csv("Data.csv")
|
276 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
@@ -332,7 +355,9 @@ Complete the following code to answer the user's question:
|
|
332 |
'pd': pd,
|
333 |
'plt': plt,
|
334 |
'os': os,
|
335 |
-
'uuid': __import__('uuid')
|
|
|
|
|
336 |
}
|
337 |
|
338 |
exec(full_code, global_vars, local_vars)
|
|
|
244 |
# Professional matplotlib styling
|
245 |
parameters = {
|
246 |
"font.size": 11,
|
247 |
+
"figure.dpi": 300,
|
248 |
"figure.facecolor": "white",
|
249 |
"axes.facecolor": "white",
|
250 |
"axes.edgecolor": "#e2e8f0",
|
|
|
269 |
import pandas as pd
|
270 |
import matplotlib.pyplot as plt
|
271 |
import uuid
|
272 |
+
import calendar
|
273 |
+
import numpy as np
|
274 |
|
275 |
+
# Set professional matplotlib styling
|
276 |
+
plt.rcParams.update({{
|
277 |
+
'font.size': 11,
|
278 |
+
'figure.dpi': 300,
|
279 |
+
'figure.facecolor': 'white',
|
280 |
+
'axes.facecolor': 'white',
|
281 |
+
'axes.edgecolor': '#e2e8f0',
|
282 |
+
'axes.linewidth': 1.2,
|
283 |
+
'axes.labelcolor': '#374151',
|
284 |
+
'axes.spines.top': False,
|
285 |
+
'axes.spines.right': False,
|
286 |
+
'axes.spines.left': True,
|
287 |
+
'axes.spines.bottom': True,
|
288 |
+
'axes.grid': True,
|
289 |
+
'grid.color': '#f1f5f9',
|
290 |
+
'grid.linewidth': 0.8,
|
291 |
+
'grid.alpha': 0.7,
|
292 |
+
'xtick.color': '#6b7280',
|
293 |
+
'ytick.color': '#6b7280',
|
294 |
+
'text.color': '#374151',
|
295 |
+
'figure.figsize': [12, 6]
|
296 |
+
}})
|
297 |
|
298 |
df = pd.read_csv("Data.csv")
|
299 |
df["Timestamp"] = pd.to_datetime(df["Timestamp"])
|
|
|
355 |
'pd': pd,
|
356 |
'plt': plt,
|
357 |
'os': os,
|
358 |
+
'uuid': __import__('uuid'),
|
359 |
+
'calendar': __import__('calendar'),
|
360 |
+
'np': __import__('numpy')
|
361 |
}
|
362 |
|
363 |
exec(full_code, global_vars, local_vars)
|