feat: input class registry and unregistered model fallback#99
Conversation
- Add register_input/get_input_class to celeste.io for capability-based Input class discovery - Register Input classes in all capability packages during initialization - Allow unregistered models when provider and capability are explicit, with warning about disabled parameter validation - Export new functions from celeste package - Update test to verify new warning behavior
- Add seedance-1-5-pro-251215 with 4-12s duration, 480p/720p resolution - Fix gradium py.typed marker file (should be empty) - Reorder google pyproject.toml sections - Update .gitignore for temporary files
Code Review - PR #99: Input Class Registry and Unregistered Model FallbackOverviewThis PR introduces two significant enhancements to Celeste's registration system. The implementation is well-structured and addresses real user needs. Overall, this is a solid contribution with good test coverage (83%). ✅ Strengths1. Input Class Registry DesignThe new registry pattern in
2. Unregistered Model FallbackThe fallback mechanism in
3. Test CoverageThe updated test in
4. Consistent Package UpdatesAll four capability packages uniformly register their Input classes during initialization, maintaining symmetry across the codebase. 🔍 Issues & ConcernsCRITICAL: Missing Test Coverage for Input RegistryLocation: The new Recommended tests: # tests/unit_tests/test_io.py (new file)
def test_register_and_get_input_class():
"""Test input class registration and retrieval."""
# Test successful registration and retrieval
# Test KeyError when capability not registered
# Test overwriting existing registration (if allowed)Impact: Medium-High (core functionality untested) MODERATE: Incomplete Test for Unregistered Model FallbackLocation: The current test mocks
Recommended improvements: def test_create_client_unregistered_model_creates_dynamic_model():
"""Test that dynamic model has correct attributes."""
with (
patch("celeste.get_model") as mock_get_model,
patch("celeste.get_client_class") as mock_client_class,
pytest.warns(UserWarning, match="not registered"),
):
mock_get_model.return_value = None
mock_client = Mock()
mock_client_class.return_value = mock_client
create_client(
capability=Capability.TEXT_GENERATION,
provider=Provider.OPENAI,
model="new-model-2025",
)
# Verify the dynamic model passed to client
call_args = mock_client_class.call_args
dynamic_model = call_args.kwargs['model']
assert dynamic_model.id == "new-model-2025"
assert dynamic_model.provider == Provider.OPENAI
assert Capability.TEXT_GENERATION in dynamic_model.capabilities
assert dynamic_model.streaming is True
def test_unregistered_model_without_capability_raises_error():
"""Test that missing capability prevents fallback."""
with patch("celeste.get_model") as mock_get_model:
mock_get_model.return_value = None
with pytest.raises(ValueError, match="Specify 'capability' explicitly"):
create_client(provider=Provider.OPENAI, model="new-model")Impact: Medium (partial validation of critical feature) MINOR: Potential Registry Race ConditionLocation: The module-level Consideration:
Impact: Low (unlikely in practice, but worth documenting) MINOR: Gitignore ChangesLocation: Adding
Impact: Low (may affect future contributors) MINOR: Empty py.typed FileLocation: The PR removes content from this file, leaving it empty. This is actually correct per PEP 561 (empty marker file), but the change appears incidental. Question: Was the previous Impact: Negligible (correctly implements PEP 561) 🛡️ Security AssessmentNo Critical Security Issues Found✅ No injection vulnerabilities: Model IDs are validated through registry or explicitly provided RecommendationThe warning message at warnings.warn(
f"Model '{model}' not registered in Celeste for provider {provider.value}. "
"Parameter validation and safety checks are DISABLED. "
"Use only with trusted model IDs from official provider documentation.",
UserWarning,
stacklevel=3,
)🚀 Performance Considerations✅ Minimal overhead: Registry lookups are O(1) dict operations No performance concerns identified. 📋 Additional Observations1. BytePlus Model AdditionThe new Seedance 1.5 Pro model (
2. Pyproject.toml ReorderingThe change in 3. Type SafetyThe code maintains strong typing throughout:
📝 Recommendations Summary
✅ Approval RecommendationApprove with minor revisions This PR delivers valuable functionality and is well-implemented. The input registry pattern is clean, and the unregistered model fallback addresses a real user need. Before merging:
The existing 316 passing tests and 83% coverage demonstrate overall quality, but the new registry functions deserve explicit test coverage. Great work on this feature! The capability-based input discovery will simplify client implementations significantly. 🎉 |
Pull Request Review: Input Class Registry and Unregistered Model FallbackSummaryThis PR introduces two important enhancements to Celeste's registration system: a capability-based Input class registry and a fallback mechanism for unregistered models. Overall, the implementation is well-designed and production-ready, with good test coverage (83%) and proper warning mechanisms. Strengths1. Clean Architecture
2. Thoughtful Unregistered Model Handling
3. Consistent Implementation
4. Good Test Coverage
Code Quality ObservationsMinor Issues
Security and SafetyExcellent Security Practices
Potential ConcernsBypassing Parameter Validation: When using unregistered models, parameter validation is completely disabled. Users could pass invalid parameters that might cause runtime errors downstream. The warning clearly states "Parameter validation disabled" which is good mitigation. Consider documenting common pitfalls in docstrings or user guide. Potential Bugs and Edge CasesCritical: KeyError Risk in get_input_classLocation: src/celeste/io.py:54-59 When using the new unregistered model fallback, if someone calls get_input_class() with a capability that hasn't been loaded yet, this will raise a KeyError. Recommendation: Call _load_from_entry_points() in get_input_class() before checking the registry (similar to list_models in src/celeste/models.py:118-120) Minor: No Validation on register_input OverwriteLocation: src/celeste/io.py:49-51 Silently overwrites if called twice with different classes for the same capability. Consider adding a warning similar to the model registry's display name validation (src/celeste/models.py:60-64). Performance Considerations
No performance concerns identified. Test CoverageWhat's Tested
What Could Be Tested
BytePlus Seedance 1.5 Pro AdditionLocation: packages/capabilities/video-generation/src/celeste_video_generation/providers/byteplus/models.py:99-115
These constraints look intentional based on model capabilities. Final VerdictApproval Status: APPROVE WITH MINOR SUGGESTIONSThis PR is well-implemented and ready to merge with only minor, non-blocking suggestions. Must Fix Before Merge: NoneShould Fix (Recommended):
Nice to Have:
SummaryExcellent work on this feature! The implementation is clean, well-tested, and follows established patterns in the codebase. The unregistered model fallback is particularly thoughtful in its safeguards. The input registry is a logical extension of the existing architecture. The suggested fixes are minor and primarily defensive programming improvements. The PR demonstrates good software engineering practices with consistent version bumping, proper test coverage, and attention to backward compatibility. Recommendation: Merge after addressing the get_input_class() lazy loading issue to prevent potential KeyError in edge cases. |
Summary
This PR introduces two core enhancements to Celeste's registration system:
Input Class Registry
Adds a capability-based Input class registry (
register_input/get_input_class) that allows runtime discovery of the correct Input type for any capability. Each capability package now registers its Input class during initialization, enabling dynamic input type resolution.Unregistered Model Fallback
Previously, using an unknown model ID would raise
ModelNotFoundError. Now, when bothproviderandcapabilityare explicitly specified, Celeste:UserWarningthat parameter validation is disabledThis enables using new or unreleased provider models before they're added to Celeste's registry.
Additional Changes
Test plan