Skip to content

Enhance proxy CLI with Rich formatting and improved user experience #11420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 7, 2025

Conversation

colesmcintosh
Copy link
Collaborator

@colesmcintosh colesmcintosh commented Jun 4, 2025

Title

🚄 Enhance LiteLLM Proxy CLI with Rich formatting and improved UX

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature
🚄 Infrastructure
✅ Test

Changes

CLI Enhancement with Rich Library

Enhanced litellm/proxy/proxy_cli.py:

  • Beautiful startup banners with centered panels and consistent branding
  • Progress indicators for long-running operations (health checks, database setup, IAM token generation)
  • Structured tables for health check results with color-coded status
  • Rich help formatting with organized sections and emoji icons
  • Consistent bullet train emoji throughout CLI (replacing rockets for unified branding)
  • Enhanced error handling with beautiful error panels and helpful messages
  • Responsive panels that adapt to terminal width

Enhanced litellm/proxy/proxy_server.py:

  • Beautiful feedback box with modern Rich panels replacing ASCII art
  • Styled thank you messages with proper spacing and typography
  • Enhanced help panels with clear call-to-action formatting
  • Graceful fallback to original formatting if Rich is unavailable

Updated tests/test_litellm/proxy/test_proxy_cli.py:

  • Modernized test assertions to work with Rich console output
  • Maintained test coverage while supporting new Rich-based implementation
  • Focused on behavior testing rather than specific string matching

Visual Improvements

Before:

LiteLLM: Current Version = 1.0.0
LiteLLM: Health Testing models in config

After:

image

Technical Details

  • Rich dependency: Already included in requirements.txt (v13.7.1)
  • Backward compatibility: Fallback mechanisms for environments without Rich
  • Performance: Minimal overhead, Rich only used for CLI output
  • Maintainability: Clean separation between UI and logic
  • Accessibility: Better contrast and visual hierarchy

User Experience Improvements

  1. Clearer visual hierarchy with panels and borders
  2. Real-time feedback with progress spinners
  3. Better error communication with styled error messages
  4. Consistent branding with bullet train emoji (🚄)
  5. Professional appearance suitable for enterprise use
  6. Helpful guidance with enhanced help formatting

Code Quality

  • Type hints preserved throughout the codebase
  • Error handling improved with Rich panel formatting
  • Tests updated to work with new Rich implementation
  • No breaking changes to existing functionality
  • Graceful degradation when Rich is unavailable

This enhancement significantly improves the developer experience when using LiteLLM Proxy CLI while maintaining full backward compatibility and test coverage.

- Integrated Rich library for better console output in `proxy_cli.py`, including version display, health check results, and test completion responses.
- Updated health check and test completion methods to provide progress indicators and formatted tables.
- Refactored feedback display in `proxy_server.py` to use Rich for a more visually appealing user interface.
- Adjusted tests in `test_proxy_cli.py` to mock console output instead of using print statements, ensuring compatibility with Rich formatting.
Copy link

vercel bot commented Jun 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 11:59pm

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed

- Removed progress indicators for IAM token generation and environment variable decryption to simplify the code.
- Consolidated the logic for generating the database URL and setting environment variables.
- Enhanced error handling for configuration loading and database setup, ensuring clearer feedback
…del display. Added support for loading model parameters from environment variables and refined provider identification logic. Fallback to original print formatting if Rich is not available.
…tom warning display to utils.py. Enhanced feedback box with rich formatting and fallback to ASCII for environments without rich. Cleaned up proxy_server.py by removing obsolete code.
Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly looks good

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested changes

…ic to a new utility function `display_model_initialization` for improved readability and maintainability. Enhanced model provider extraction with a dedicated function. Fallback to basic logging if Rich console is unavailable.
…om_model` function with a more robust approach using `get_llm_provider`. Implement fallback logic for provider identification and improve error handling. Ensure compatibility with Rich console for model initialization display.
Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ishaan-jaff ishaan-jaff merged commit 3b911ba into BerriAI:main Jun 7, 2025
6 checks passed
ishaan-jaff added a commit that referenced this pull request Jun 7, 2025
stefan-- pushed a commit to stefan--/litellm that referenced this pull request Jun 12, 2025
…erriAI#11420)

* Enhance proxy CLI with Rich formatting and improved user experience

- Integrated Rich library for better console output in `proxy_cli.py`, including version display, health check results, and test completion responses.
- Updated health check and test completion methods to provide progress indicators and formatted tables.
- Refactored feedback display in `proxy_server.py` to use Rich for a more visually appealing user interface.
- Adjusted tests in `test_proxy_cli.py` to mock console output instead of using print statements, ensuring compatibility with Rich formatting.

* fix linting error

* refactor(proxy_cli.py): simplify DB setup logging

- Removed progress indicators for IAM token generation and environment variable decryption to simplify the code.
- Consolidated the logic for generating the database URL and setting environment variables.
- Enhanced error handling for configuration loading and database setup, ensuring clearer feedback

* Update test-linting workflow to include proxy-dev dependencies in Poetry installation

* Enhance proxy server initialization with Rich console for improved model display. Added support for loading model parameters from environment variables and refined provider identification logic. Fallback to original print formatting if Rich is not available.

* Refactor feedback handling: Moved feedback message generation and custom warning display to utils.py. Enhanced feedback box with rich formatting and fallback to ASCII for environments without rich. Cleaned up proxy_server.py by removing obsolete code.

* fix linting error

* Refactor model initialization display: Moved model initialization logic to a new utility function `display_model_initialization` for improved readability and maintainability. Enhanced model provider extraction with a dedicated function. Fallback to basic logging if Rich console is unavailable.

* Refactor model provider extraction: Replace the `_extract_provider_from_model` function with a more robust approach using `get_llm_provider`. Implement fallback logic for provider identification and improve error handling. Ensure compatibility with Rich console for model initialization display.
stefan-- pushed a commit to stefan--/litellm that referenced this pull request Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants