Deep fix: CSS loading order and exact test_image.py plot settings
Browse files- Moved critical CSS to top of file with \!important flags for instant blue styling
- Applied exact test_image.py settings: 9x6 figsize @ 1200 DPI
- Creates 10,800x7,200 pixel images for ultra-sharp display
- Display width set to 1080px for perfect 10:1 pixel density
- Both UI responsiveness and plot quality issues resolved
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- app.py +32 -3
- new_system_prompt.txt +4 -4
- src.py +1 -1
- vayuchat.mplstyle +1 -1
    	
        app.py
    CHANGED
    
    | @@ -36,6 +36,35 @@ st.set_page_config( | |
| 36 | 
             
                initial_sidebar_state="expanded"
         | 
| 37 | 
             
            )
         | 
| 38 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 39 | 
             
            # JavaScript for interactions
         | 
| 40 | 
             
            # st.markdown("""
         | 
| 41 | 
             
            # <script>
         | 
| @@ -419,7 +448,7 @@ def show_custom_response(response): | |
| 419 | 
             
                content = response.get("content", "")
         | 
| 420 |  | 
| 421 | 
             
                if role == "user":
         | 
| 422 | 
            -
                    # User message with right alignment -  | 
| 423 | 
             
                    st.markdown(f"""
         | 
| 424 | 
             
                    <div style='display: flex; justify-content: flex-end; margin: 1rem 0;'>
         | 
| 425 | 
             
                        <div class='user-message'>
         | 
| @@ -506,7 +535,7 @@ def show_custom_response(response): | |
| 506 | 
             
                                <div style='margin: 1rem 0; display: flex; justify-content: center;'>
         | 
| 507 | 
             
                                </div>
         | 
| 508 | 
             
                                """, unsafe_allow_html=True)
         | 
| 509 | 
            -
                                st.image(content, width= | 
| 510 | 
             
                                return {"is_image": True}
         | 
| 511 | 
             
                        # Also handle case where content shows filename but we want to show image
         | 
| 512 | 
             
                        elif isinstance(content, str) and any(ext in content for ext in ['.png', '.jpg']):
         | 
| @@ -520,7 +549,7 @@ def show_custom_response(response): | |
| 520 | 
             
                                    <div style='margin: 1rem 0; display: flex; justify-content: center;'>
         | 
| 521 | 
             
                                    </div>
         | 
| 522 | 
             
                                    """, unsafe_allow_html=True)
         | 
| 523 | 
            -
                                    st.image(filename, width= | 
| 524 | 
             
                                    return {"is_image": True}
         | 
| 525 | 
             
                    except:
         | 
| 526 | 
             
                        pass
         | 
|  | |
| 36 | 
             
                initial_sidebar_state="expanded"
         | 
| 37 | 
             
            )
         | 
| 38 |  | 
| 39 | 
            +
            # CRITICAL: CSS must be loaded FIRST for immediate blue message styling
         | 
| 40 | 
            +
            st.markdown("""
         | 
| 41 | 
            +
            <style>
         | 
| 42 | 
            +
            /* User message styling - MUST be defined early */
         | 
| 43 | 
            +
            .user-message {
         | 
| 44 | 
            +
                background: #3b82f6 !important;
         | 
| 45 | 
            +
                color: white !important;
         | 
| 46 | 
            +
                padding: 0.75rem 1rem !important;
         | 
| 47 | 
            +
                border-radius: 7px !important;
         | 
| 48 | 
            +
                max-width: 95% !important;
         | 
| 49 | 
            +
            }
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            /* Assistant message styling */
         | 
| 52 | 
            +
            .assistant-message {
         | 
| 53 | 
            +
                background: #f1f5f9 !important;
         | 
| 54 | 
            +
                color: #334155 !important;
         | 
| 55 | 
            +
                padding: 0.75rem 1rem !important;
         | 
| 56 | 
            +
                border-radius: 12px !important;
         | 
| 57 | 
            +
                max-width: 85% !important;
         | 
| 58 | 
            +
            }
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            .assistant-info {
         | 
| 61 | 
            +
                font-size: 0.875rem !important;
         | 
| 62 | 
            +
                color: #6b7280 !important;
         | 
| 63 | 
            +
                margin-bottom: 5px !important;
         | 
| 64 | 
            +
            }
         | 
| 65 | 
            +
            </style>
         | 
| 66 | 
            +
            """, unsafe_allow_html=True)
         | 
| 67 | 
            +
             | 
| 68 | 
             
            # JavaScript for interactions
         | 
| 69 | 
             
            # st.markdown("""
         | 
| 70 | 
             
            # <script>
         | 
|  | |
| 448 | 
             
                content = response.get("content", "")
         | 
| 449 |  | 
| 450 | 
             
                if role == "user":
         | 
| 451 | 
            +
                    # User message with right alignment - CSS now loaded at top of file
         | 
| 452 | 
             
                    st.markdown(f"""
         | 
| 453 | 
             
                    <div style='display: flex; justify-content: flex-end; margin: 1rem 0;'>
         | 
| 454 | 
             
                        <div class='user-message'>
         | 
|  | |
| 535 | 
             
                                <div style='margin: 1rem 0; display: flex; justify-content: center;'>
         | 
| 536 | 
             
                                </div>
         | 
| 537 | 
             
                                """, unsafe_allow_html=True)
         | 
| 538 | 
            +
                                st.image(content, width=1080, caption="Generated Visualization")
         | 
| 539 | 
             
                                return {"is_image": True}
         | 
| 540 | 
             
                        # Also handle case where content shows filename but we want to show image
         | 
| 541 | 
             
                        elif isinstance(content, str) and any(ext in content for ext in ['.png', '.jpg']):
         | 
|  | |
| 549 | 
             
                                    <div style='margin: 1rem 0; display: flex; justify-content: center;'>
         | 
| 550 | 
             
                                    </div>
         | 
| 551 | 
             
                                    """, unsafe_allow_html=True)
         | 
| 552 | 
            +
                                    st.image(filename, width=1080, caption="Generated Visualization")
         | 
| 553 | 
             
                                    return {"is_image": True}
         | 
| 554 | 
             
                    except:
         | 
| 555 | 
             
                        pass
         | 
    	
        new_system_prompt.txt
    CHANGED
    
    | @@ -33,11 +33,11 @@ DATA SAFETY: | |
| 33 | 
             
            - Use .dropna() to remove missing values before analysis
         | 
| 34 |  | 
| 35 | 
             
            PLOTTING REQUIREMENTS:
         | 
| 36 | 
            -
            - Create plots for visualization requests: fig, ax = plt.subplots(figsize=( | 
| 37 | 
            -
            -  | 
| 38 | 
            -
            -  | 
|  | |
| 39 | 
             
            - For non-plots: answer = "text result"
         | 
| 40 | 
            -
            - NEVER use plt.savefig() - always use st.pyplot(fig) for direct display
         | 
| 41 |  | 
| 42 | 
             
            BASIC ERROR PREVENTION:
         | 
| 43 | 
             
            - Use try/except for complex operations
         | 
|  | |
| 33 | 
             
            - Use .dropna() to remove missing values before analysis
         | 
| 34 |  | 
| 35 | 
             
            PLOTTING REQUIREMENTS:
         | 
| 36 | 
            +
            - Create plots for visualization requests: fig, ax = plt.subplots(figsize=(9, 6))
         | 
| 37 | 
            +
            - Save plots with ULTRA high resolution: filename = f"plot_{uuid.uuid4().hex[:8]}.png"; plt.savefig(filename, dpi=1200, bbox_inches='tight', facecolor='white', edgecolor='none')
         | 
| 38 | 
            +
            - Close plots: plt.close()
         | 
| 39 | 
            +
            - Store filename: answer = filename
         | 
| 40 | 
             
            - For non-plots: answer = "text result"
         | 
|  | |
| 41 |  | 
| 42 | 
             
            BASIC ERROR PREVENTION:
         | 
| 43 | 
             
            - Use try/except for complex operations
         | 
    	
        src.py
    CHANGED
    
    | @@ -149,7 +149,7 @@ def ask_question(model_name, question): | |
| 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'] = [ | 
| 153 | 
             
                    plt.rcParams['figure.facecolor'] = 'white'
         | 
| 154 | 
             
                    plt.rcParams['savefig.facecolor'] = 'white'
         | 
| 155 | 
             
                    plt.rcParams['savefig.bbox'] = 'tight'
         | 
|  | |
| 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'] = [9, 6]
         | 
| 153 | 
             
                    plt.rcParams['figure.facecolor'] = 'white'
         | 
| 154 | 
             
                    plt.rcParams['savefig.facecolor'] = 'white'
         | 
| 155 | 
             
                    plt.rcParams['savefig.bbox'] = 'tight'
         | 
    	
        vayuchat.mplstyle
    CHANGED
    
    | @@ -16,7 +16,7 @@ legend.fontsize: 9 | |
| 16 | 
             
            figure.dpi: 1200
         | 
| 17 | 
             
            figure.facecolor: white
         | 
| 18 | 
             
            figure.edgecolor: none
         | 
| 19 | 
            -
            figure.figsize:  | 
| 20 | 
             
            figure.autolayout: True
         | 
| 21 |  | 
| 22 | 
             
            # Modern Color Palette (inspired by Tailwind/GitHub)
         | 
|  | |
| 16 | 
             
            figure.dpi: 1200
         | 
| 17 | 
             
            figure.facecolor: white
         | 
| 18 | 
             
            figure.edgecolor: none
         | 
| 19 | 
            +
            figure.figsize: 9, 6
         | 
| 20 | 
             
            figure.autolayout: True
         | 
| 21 |  | 
| 22 | 
             
            # Modern Color Palette (inspired by Tailwind/GitHub)
         | 

