feat: add multi-capability model registration and new providers#12
Conversation
- Add multi-capability support: register_models now accepts capability parameter and merges models - Add BYTEDANCE provider and credential support - Add IMAGE_INTELLIGENCE capability - Add _handle_error_response method to Client for better error handling - Update Model class field order (display_name before capabilities) - Update all tests for new registration pattern
Pull Request Review: Multi-Capability Model RegistrationSummaryThis PR introduces multi-capability model registration support, new providers (ByteDance), and improved error handling. The implementation is well-designed with good test coverage. Code Quality & Best Practices ✅Strengths
Suggestions for Improvement1. Error Handling in
|
- Remove unnecessary AttributeError catch (only JSONDecodeError needed) - Use httpx.HTTPStatusError instead of ValueError for better error context - Improve error message extraction with fallback handling - Remove deprecated capabilities field from Model instantiations in tests
Models registered with capabilities differ from original instances since capabilities are added during registration. Compare individual fields instead of full model equality.
Code Review: Multi-Capability Model RegistrationSummaryThis PR introduces a valuable feature allowing models to be registered for multiple capabilities with proper merging logic. The implementation is generally solid with good test coverage. ✅ Strengths
🔍 Code Quality & Best PracticesBreaking API Change (Location: src/celeste/models.py:28)The register_models() function signature changed from accepting only models to requiring a capability parameter. This is a BREAKING CHANGE for external packages. Recommendations:
Subtle Logic Issue (Location: src/celeste/models.py:46-55)The setdefault() implementation creates unused Model instances when the key already exists. Consider using explicit if-check instead. Error Handling (Location: src/celeste/client.py:63-78)The new _handle_error_response() method is not called anywhere. Either document its intended use for subclasses or remove if premature. 🐛 Potential BugsParameter Constraint Merging (src/celeste/models.py:66)What happens if the same parameter is registered with different constraints for different capabilities? The dict.update() will overwrite previous constraints. Please clarify if this is intentional and add test cases. 🚀 PerformanceMinor: setdefault() creates unused instances, but overall performance impact is negligible. 🔒 Security
🧪 Test CoverageExcellent coverage overall. Missing test cases:
📝 DocumentationPlease add:
🎯 RecommendationsHigh Priority
Medium Priority
✅ ConclusionThis is a well-implemented feature with solid test coverage. Main concerns are the breaking API change documentation and parameter constraint merging behavior clarification. Code quality is high and follows project conventions. Recommendation: Request clarifications on constraint merging and ensure breaking changes are documented before merging. |
Summary
This PR adds multi-capability model registration support and introduces new providers and capabilities.
Multi-Capability Model Registration
register_models()now acceptscapabilityparameter to support registering the same model for multiple capabilitiesNew Provider & Capability
BYTEDANCEprovider supportBYTEDANCEcredential managementIMAGE_INTELLIGENCEcapabilityError Handling
_handle_error_response()method toClientbase class for better API error handlingCode Quality
display_namebeforecapabilities)Changes
src/celeste/models.py: Multi-capability registration with merging logicsrc/celeste/core.py: Added BYTEDANCE provider and IMAGE_INTELLIGENCE capabilitysrc/celeste/credentials.py: Added BYTEDANCE credential supportsrc/celeste/client.py: Added error handling methodtests/unit_tests/test_models.py: Updated all tests for new patternTesting
All tests pass and linting/type checking passes.