Fix processing indicator and improve system prompt
Browse files- Fix processing indicator appearing in old messages - now shows only once at bottom
- Remove custom processing function, use simple st.spinner
- Simplify system prompt with general coding practices instead of specific error fixes
- Focus on fundamental pandas/Python best practices for better LLM code generation
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
app.py
CHANGED
@@ -759,9 +759,6 @@ def show_custom_response(response):
|
|
759 |
|
760 |
return {"is_image": False}
|
761 |
|
762 |
-
def show_processing_indicator(model_name, question):
|
763 |
-
"""Simple processing indicator"""
|
764 |
-
st.info(f"Processing with {model_name}...")
|
765 |
|
766 |
# Chat history
|
767 |
# Display chat history
|
@@ -806,12 +803,10 @@ for response_id, response in enumerate(st.session_state.responses):
|
|
806 |
st.success("Thanks for your feedback!")
|
807 |
st.rerun()
|
808 |
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
st.session_state.get("current_question", "Processing...")
|
814 |
-
)
|
815 |
|
816 |
# Chat input with better guidance
|
817 |
prompt = st.chat_input("💬 Ask about air quality trends, compare cities, or request visualizations...", key="main_chat")
|
|
|
759 |
|
760 |
return {"is_image": False}
|
761 |
|
|
|
|
|
|
|
762 |
|
763 |
# Chat history
|
764 |
# Display chat history
|
|
|
803 |
st.success("Thanks for your feedback!")
|
804 |
st.rerun()
|
805 |
|
806 |
+
# Show processing indicator if processing (only once at the bottom)
|
807 |
+
if st.session_state.get("processing"):
|
808 |
+
with st.spinner(f"Processing with {st.session_state.get('current_model', 'Unknown')}..."):
|
809 |
+
pass
|
|
|
|
|
810 |
|
811 |
# Chat input with better guidance
|
812 |
prompt = st.chat_input("💬 Ask about air quality trends, compare cities, or request visualizations...", key="main_chat")
|
src.py
CHANGED
@@ -310,14 +310,13 @@ SAFETY & ROBUSTNESS RULES:
|
|
310 |
- Validate date ranges exist in data
|
311 |
- Use proper string formatting for answers with units (μg/m³)
|
312 |
|
313 |
-
CRITICAL
|
314 |
-
-
|
315 |
-
-
|
316 |
-
-
|
317 |
-
-
|
318 |
-
-
|
319 |
-
-
|
320 |
-
- Use proper DataFrame column references in all operations
|
321 |
|
322 |
TECHNICAL REQUIREMENTS:
|
323 |
- Save final result in variable called 'answer'
|
|
|
310 |
- Validate date ranges exist in data
|
311 |
- Use proper string formatting for answers with units (μg/m³)
|
312 |
|
313 |
+
CRITICAL CODING PRACTICES:
|
314 |
+
- Always convert pandas/numpy objects to proper Python types before operations
|
315 |
+
- Use descriptive variable names (avoid single letters in complex logic)
|
316 |
+
- Ensure all variables are defined before use
|
317 |
+
- Convert datetime/period objects to appropriate types (.astype(str), .astype(int))
|
318 |
+
- Reference DataFrame properly in all column operations: df['column'] not 'column'
|
319 |
+
- Use proper data type checking and conversion for all operations
|
|
|
320 |
|
321 |
TECHNICAL REQUIREMENTS:
|
322 |
- Save final result in variable called 'answer'
|