Nipun Claude commited on
Commit
7a86a16
·
1 Parent(s): 57ba99b

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]>

Files changed (2) hide show
  1. app.py +4 -9
  2. src.py +7 -8
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
- # Show processing indicator if processing
810
- if st.session_state.get("processing"):
811
- show_processing_indicator(
812
- st.session_state.get("current_model", "Unknown"),
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: PANDAS SYNTAX FIXES:
314
- - ALWAYS convert pandas/numpy values to int before using as list indices
315
- - Example: calendar.month_name[int(month_value)] NOT calendar.month_name[month_value]
316
- - Use int() conversion for ANY value used as index: int(row['month']), int(max_idx), etc.
317
- - When accessing pandas iloc results, wrap in int(): int(df.loc[idx, 'column'])
318
- - CORRECT groupby syntax: df.groupby([df['col1'], df['col2'].dt.year]) NOT df.groupby(['col1', 'col2'].dt.year)
319
- - Always reference DataFrame when accessing columns: df['column'].dt.year NOT 'column'].dt.year
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'