feat(providers): add BFL Images API package#81
Conversation
Add standalone provider package for BFL Images API with mixin pattern
for capability-agnostic reuse.
## Client (BFLImagesClient mixin)
- Async polling workflow for image generation
- Phase 1: POST to /v1/{model_id} to submit job
- Phase 2: Poll GET polling_url until Ready/Failed
- _parse_content() extracts result from response
- _parse_finish_reason() maps BFL status to FinishReason
- Merges _submit_metadata into final response for usage tracking
- Configurable polling interval (0.5s) and timeout (120s)
## Parameters
- WidthMapper: image width
- HeightMapper: image height
- SeedMapper: reproducible generation seed
- StepsMapper: inference steps
- GuidanceMapper: guidance scale
- PromptUpsamplingMapper: prompt enhancement
- SafetyToleranceMapper: content safety level
- OutputFormatMapper: output image format
## Config
- API base URL: https://api.bfl.ai
- Endpoint: /v1/{model_id}
- Polling interval: 0.5 seconds
- Polling timeout: 120 seconds
## Other
- py.typed marker for typed package support
Move usage field mapping from capability layer to API layer mixin, following the established pattern from Anthropic and Google providers. ## API Layer Changes (celeste_bfl) - Add map_usage_fields() static method with UsageField enum - Add _parse_usage() that extracts _submit_metadata and maps fields - Maps: cost → BILLED_UNITS, input_mp → INPUT_MP, output_mp → OUTPUT_MP ## Capability Layer Changes (image-generation) - Simplify _parse_usage() to call super()._parse_usage() and wrap result - Add celeste-bfl workspace dependency to pyproject.toml
Code Review: BFL Images API Provider PackageSummaryThis PR successfully introduces a standalone ✅ StrengthsArchitecture & Design
Code Quality
🔍 Issues & Recommendations1. CRITICAL: Missing Dependencies in pyproject.tomlFile: packages/providers/bfl/pyproject.toml The provider package is missing runtime dependencies. Compare with celeste-google which has dependencies = ["celeste-ai", "httpx"]. This needs to be added. Impact: The package will not be installable standalone - users will get import errors. 2. BUG FIX: Inconsistent Return TypeStatus: Fixed! The old code could return None but the new implementation correctly always returns a FinishReason object. Well done! 3. MISSING: No Unit Tests for Provider PackageLocation: packages/providers/bfl/tests/ (does not exist) Other providers have comprehensive unit tests. Add tests especially for usage mapping and parameter mappers. 4. MISSING: Entry Point RegistrationDoes BFL need an entry point registration like celeste-google has? This should be clarified. 5. POTENTIAL BUG: Polling Timeout Edge CaseIf a request takes a long time near the timeout, the sleep could push past the timeout. Consider checking timeout before sleep. 6. PERFORMANCE: Polling Interval0.5s polling means up to 240 requests over 2 minutes. Consider exponential backoff or document if this is the recommended interval. 7. MINOR: Unused Utility FunctionThe encode_image() function is defined but never used. Is this for future functionality? 8. TYPE SAFETY: Type Ignore CommentsMultiple type ignore comments. Consider using a Protocol for better typing (nice-to-have). 🛡️ Security✅ No Security Concerns - Proper authentication, no hardcoded credentials, appropriate timeout handling 🧪 Test Coverage
📊 Performance Considerations
🎯 Final RecommendationsMust Fix Before Merge
Should Address
Nice to Have
✨ Overall AssessmentScore: 8/10 - This is solid work that follows established patterns and significantly improves code organization. The main blocker is the missing dependencies in pyproject.toml. Once that is fixed and tests are added, this will be ready to merge. The architectural decision to extract the provider layer is excellent and sets up the codebase well for future BFL capabilities beyond image generation. Great job on following the existing patterns! 🚀 |
- Enhanced Int constraint to accept int, str, float (whole numbers only) - Updated BFL WidthMapper and HeightMapper to use Int() directly - Fixes AttributeError when AspectRatioMapper calls internal mappers
PR Review: BFL Images API Provider PackageSummaryThis PR successfully implements a standalone ✅ StrengthsArchitecture & Design
Code Quality
Testing
🔍 Issues Found1. Missing
|
Summary
Add standalone
celeste-bflprovider package with Images API mixin, following the established pattern from Anthropic and Google providers.Changes
Provider Package (
celeste-bfl)/v1/{model_id}to submit jobpolling_urluntil Ready/Failed_submit_metadatainto final response for usage trackingmap_usage_fields()static method withUsageFieldenum_parse_usage()extracts and maps BFL fields (cost → BILLED_UNITS, input_mp → INPUT_MP, output_mp → OUTPUT_MP)py.typedmarker for typed package supportCapability Package (
celeste-image-generation)_parse_usage()to callsuper()._parse_usage()and wrap resultceleste-bflworkspace dependencyconfig.py(now in provider layer)Test plan