Eliminate redundant code by leveraging existing utilities, extracting reusable helper functions, and organizing logic in appropriate modules. Before implementing new functionality, check if similar logic already exists in the codebase that can be reused or extended.
Eliminate redundant code by leveraging existing utilities, extracting reusable helper functions, and organizing logic in appropriate modules. Before implementing new functionality, check if similar logic already exists in the codebase that can be reused or extended.
Key practices:
get_deployment
in router.py rather than duplicating deployment lookup logic)Example of refactoring duplicate logic:
# Before: Duplicate SSL verification logic
ssl_verify = (os.getenv("SSL_VERIFY") != "False") if os.getenv("SSL_VERIFY") is not None else litellm.ssl_verify
# After: Extract to helper method
def get_ssl_verify_setting():
return (os.getenv("SSL_VERIFY") != "False") if os.getenv("SSL_VERIFY") is not None else litellm.ssl_verify
ssl_verify = get_ssl_verify_setting()
This approach reduces maintenance burden, improves consistency, and makes the codebase more maintainable by centralizing common logic.
Enter the URL of a public GitHub repository