chatui-helper / ui_simplification_guide.md
milwright
Add Gradio theme selection and faculty configuration features
c36325d
|
raw
history blame
6.99 kB

UI Simplification Implementation Guide

Overview

This guide shows how to simplify the configuration interface in app.py to make it less intimidating and more space-efficient.

Key Improvements

1. Simplified Variable Names

Replace technical environment variable names with user-friendly alternatives:

# Instead of:
api_key_var = gr.Textbox(
    label="API Key Configuration (Required)",
    value="OPENROUTER_API_KEY",
    info="Set this secret in HuggingFace Space Settings..."
)

# Use:
api_key_var = gr.Textbox(
    label="API Key Name",
    value="MY_API_KEY",
    info="You'll set this in HuggingFace later"
)

2. Compact Layout

Reduce vertical space usage:

# Group related fields in rows
with gr.Row():
    model = gr.Dropdown(
        label="AI Model",
        choices=[("Fast & Smart", "google/gemini-2.0-flash-001")],
        scale=2
    )
    
    with gr.Column(scale=1):
        temperature = gr.Slider(
            label="Creativity",
            minimum=0, maximum=2, value=0.7
        )

3. Progressive Disclosure

Hide advanced options by default:

# Essential fields visible
system_prompt = gr.Textbox(
    label="Assistant Instructions",
    placeholder="Tell your assistant how to behave...",
    lines=3
)

# Advanced settings hidden
with gr.Accordion("βš™οΈ Advanced (Optional)", open=False):
    # Less common settings here

4. Friendly Labels and Descriptions

Before:

  • "System Prompt" β†’ "Assistant Instructions"
  • "Max Response Tokens" β†’ "Response Length"
  • "Temperature" β†’ "Creativity Level"
  • "Grounding URLs" β†’ "Reference Materials"
  • "Enable Dynamic URL Fetching" β†’ "Let assistant read links from chat"

5. Visual Hierarchy

Use emojis and formatting to create clear sections:

gr.Markdown("## πŸš€ Quick Setup")
gr.Markdown("### ✨ Your Assistant")
gr.Markdown("### πŸ“Ž Add Resources (Optional)")

Implementation Steps

Step 1: Update the Configuration Tab Layout

Replace the current configuration section (lines 1526-1732 in app.py) with:

with gr.Tab("Configuration"):
    gr.Markdown("# πŸš€ Create Your AI Assistant")
    gr.Markdown("Set up your custom assistant in just a few steps!")
    
    with gr.Column():
        # Simplified model selection
        model = gr.Dropdown(
            label="Choose Assistant Type",
            choices=[
                ("Fast & Smart (Recommended)", "google/gemini-2.0-flash-001"),
                ("Advanced Analysis", "anthropic/claude-3.5-haiku"),
                ("Code Specialist", "mistralai/devstral-small")
            ],
            value="google/gemini-2.0-flash-001"
        )
        
        # Main configuration card
        with gr.Group():
            gr.Markdown("### ✨ Configure Your Assistant")
            
            # Template selector at top
            template_selector = gr.Radio(
                label="Start with a template or create custom",
                choices=[
                    ("Custom", "None"),
                    ("Study Helper", "Research Template"),
                    ("Teacher", "Socratic Template")
                ],
                value="None",
                type="value"
            )
            
            system_prompt = gr.Textbox(
                label="How should your assistant behave?",
                placeholder="Example: You are a friendly tutor who explains concepts clearly...",
                lines=3
            )
            
            examples_text = gr.Textbox(
                label="Starter Questions (one per line)",
                placeholder="What can you help me with?\nExplain this concept",
                lines=2
            )
        
        # Collapsible sections for optional features
        with gr.Accordion("πŸ“Ž Add Resources (Optional)", open=False):
            url1 = gr.Textbox(
                label="Main Reference",
                placeholder="https://course-website.edu"
            )
            url2 = gr.Textbox(
                label="Additional Reference",
                placeholder="https://textbook.com"
            )
            
            enable_dynamic_urls = gr.Checkbox(
                label="Let assistant read links from conversations",
                value=True
            )
        
        with gr.Accordion("πŸ” Security (Optional)", open=False):
            api_key_var = gr.Textbox(
                label="API Key Name",
                value="MY_API_KEY",
                info="Simple name for your API key"
            )
            
            access_code = gr.Textbox(
                label="Access Password Name",
                value="SPACE_PASSWORD",
                info="Only if you want a private space"
            )
        
        # Action buttons
        with gr.Row():
            preview_btn = gr.Button("πŸ‘οΈ Preview", variant="secondary")
            generate_btn = gr.Button("πŸŽ‰ Create Assistant", variant="primary", size="lg")

Step 2: Add Mobile-Responsive CSS

Add this CSS to make the form work well on all screen sizes:

/* Add to the CSS section */
.gradio-container {
    max-width: 800px !important;
    margin: 0 auto;
}

/* Compact spacing */
.form { gap: 0.75rem !important; }

/* Mobile responsive */
@media (max-width: 768px) {
    .gradio-container { padding: 1rem !important; }
    button { width: 100%; }
    .gr-row { flex-direction: column !important; }
}

Step 3: Simplify Success Messages

Update the success message (around line 1173):

success_msg = f"""βœ… **Your assistant is ready!**

**Next steps:**
1. Download your package below
2. Create a new Space at [huggingface.co/spaces](https://huggingface.co/spaces)
3. Upload the files
4. Add your API key: `{api_key_var}` = your OpenRouter key

**That's it! Your assistant will be live in 2 minutes.**
"""

Benefits

  1. Less Intimidating: Friendly language and clear hierarchy
  2. Faster Setup: Essential fields visible, advanced hidden
  3. Mobile Friendly: Works on phones and tablets
  4. Clearer Purpose: Users understand what each field does
  5. Progressive Disclosure: Complexity revealed only when needed

Testing the Simplified UI

  1. Desktop View: Ensure all elements fit without scrolling
  2. Mobile View: Test on phone-sized screens
  3. Tablet View: Verify responsive layout
  4. Quick Setup: Time how long it takes to fill out
  5. User Testing: Get feedback from non-technical users

Variable Name Mapping

For backward compatibility, map friendly names to technical ones:

# In generate_zip function
var_mapping = {
    "MY_API_KEY": "OPENROUTER_API_KEY",
    "SPACE_PASSWORD": "SPACE_ACCESS_CODE",
    "TEACHER_PASSWORD": "FACULTY_CONFIG_PASSWORD"
}

# Use the technical name in the generated code
actual_var = var_mapping.get(api_key_var, api_key_var)

This ensures the generated spaces still work correctly while presenting friendly names to users.