Nipun Claude commited on
Commit
a60f4e3
·
1 Parent(s): 95b3c75

Fix immediate user message display and ensure high DPI in exec environment

Browse files

- User messages now appear in blue immediately without rerun delay
- Removed style file dependency in exec environment for reliable DPI
- Manual matplotlib configuration ensures 1200 DPI is always applied
- Fixed chat history to avoid message duplication during processing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (2) hide show
  1. app.py +15 -4
  2. src.py +6 -3
app.py CHANGED
@@ -526,8 +526,13 @@ def show_custom_response(response):
526
 
527
 
528
  # Chat history
529
- # Display chat history
530
  for response_id, response in enumerate(st.session_state.responses):
 
 
 
 
 
531
  status = show_custom_response(response)
532
 
533
  # Show feedback section for assistant responses
@@ -626,6 +631,15 @@ if prompt and not st.session_state.get("processing"):
626
  prompt = None
627
 
628
  if prompt:
 
 
 
 
 
 
 
 
 
629
  # Add user input to chat history
630
  user_response = get_from_user(prompt)
631
  st.session_state.responses.append(user_response)
@@ -634,9 +648,6 @@ if prompt and not st.session_state.get("processing"):
634
  st.session_state.processing = True
635
  st.session_state.current_model = model_name
636
  st.session_state.current_question = prompt
637
-
638
- # Rerun to show user message with proper styling
639
- st.rerun()
640
 
641
  # Process the question if we're in processing state
642
  if st.session_state.get("processing"):
 
526
 
527
 
528
  # Chat history
529
+ # Display chat history (skip last user message if currently processing to avoid duplication)
530
  for response_id, response in enumerate(st.session_state.responses):
531
+ # Skip showing the last user message if we're processing (already shown above)
532
+ if (st.session_state.get("processing") and
533
+ response_id == len(st.session_state.responses) - 1 and
534
+ response["role"] == "user"):
535
+ continue
536
  status = show_custom_response(response)
537
 
538
  # Show feedback section for assistant responses
 
631
  prompt = None
632
 
633
  if prompt:
634
+ # Show user message immediately with blue styling
635
+ st.markdown(f"""
636
+ <div style='display: flex; justify-content: flex-end; margin: 1rem 0;'>
637
+ <div class='user-message'>
638
+ {prompt}
639
+ </div>
640
+ </div>
641
+ """, unsafe_allow_html=True)
642
+
643
  # Add user input to chat history
644
  user_response = get_from_user(prompt)
645
  st.session_state.responses.append(user_response)
 
648
  st.session_state.processing = True
649
  st.session_state.current_model = model_name
650
  st.session_state.current_question = prompt
 
 
 
651
 
652
  # Process the question if we're in processing state
653
  if st.session_state.get("processing"):
src.py CHANGED
@@ -145,11 +145,14 @@ def ask_question(model_name, question):
145
  """Safely execute generated code and handle errors"""
146
  local_vars = {}
147
 
148
- # Force matplotlib to use high resolution settings in exec environment
149
- plt.style.use('vayuchat.mplstyle')
150
  plt.rcParams['figure.dpi'] = 1200
151
- plt.rcParams['savefig.dpi'] = 1200
152
  plt.rcParams['figure.figsize'] = [12, 7]
 
 
 
153
  plt.rcParams['font.size'] = 11
154
  plt.rcParams['axes.titlesize'] = 14
155
  plt.rcParams['axes.labelsize'] = 12
 
145
  """Safely execute generated code and handle errors"""
146
  local_vars = {}
147
 
148
+ # Force matplotlib to use ULTRA high resolution settings in exec environment
149
+ # Skip style file and set everything manually to ensure it works
150
  plt.rcParams['figure.dpi'] = 1200
151
+ plt.rcParams['savefig.dpi'] = 1200
152
  plt.rcParams['figure.figsize'] = [12, 7]
153
+ plt.rcParams['figure.facecolor'] = 'white'
154
+ plt.rcParams['savefig.facecolor'] = 'white'
155
+ plt.rcParams['savefig.bbox'] = 'tight'
156
  plt.rcParams['font.size'] = 11
157
  plt.rcParams['axes.titlesize'] = 14
158
  plt.rcParams['axes.labelsize'] = 12