feat: Adobe Firefly Services as a drop-in image provider - #36
Conversation
Demonstrates the ports-and-adapters payoff: FireflyImageGenerator implements the existing ImageGeneratorPort (Adobe IMS client-credentials auth -> Firefly v3 generate -> fetch the presigned asset -> cover-fit), and adopting it is one new adapter plus a single line at the composition root — the use case, compliance, export, and UI are untouched. - Selectable via the model picker / ?model=firefly; degrades to Imagen -> OpenRouter -> procedural when Firefly is unavailable or its credentials are absent. - 'firefly' provenance flows through to the run report and a FIREFLY badge in the grid. - Full test coverage for the adapter (mocked IMS/generate/image) and the new wiring; the repo's 100% gate stays green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code Review by Qodo
Context used✅ Compliance rules (platform):
4 rules 1. FireflyImageGenerator uses console.warn
|
|
Warning Review limit reached
More reviews will be available in 17 minutes and 17 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Every resolveBackground() ran a fresh client-credentials grant, so one
campaign run fired product × ratio token requests with up to 8 in
flight at once — avoidable latency plus a wider transient-auth failure
surface, for tokens IMS reports as ~24 h-lived. Cache {token,
expiresAt} with a 60 s refresh margin and share a single in-flight
grant between concurrent cells; a settled grant clears itself so a
failed one is retried rather than poisoning later generations.
Addresses qodo review finding #2 on PR #36.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
env.ts's provider log only knew the Imagen/OpenRouter keys, so a Firefly-only setup warned "procedural only — no GenAI keys detected" even though ?model=firefly would generate real imagery. List Firefly when both credentials are present (noting it is opt-in via model selection, not part of the default chain) and warn when only one of the two credentials is set, since that silently does nothing. Addresses qodo review finding #3 on PR #36. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
qodo review triage — each finding verified against the codebase
1 — rejected. The rule mirrors 2 — confirmed, fixed in 7eb89d2. 3 — confirmed, fixed in ffd16db. Verified locally: build, typecheck, lint, and the full suite (286/286 tests) all green. 🤖 Generated with Claude Code |
CI's 100% branch gate caught the warning's untested ternary arm (FIREFLY_CLIENT_SECRET set without FIREFLY_CLIENT_ID). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR Summary by Qodo
Add Adobe Firefly as a drop-in ImageGeneratorPort provider with graceful fallback
✨ Enhancement🧪 Tests📝 Documentation⚙️ Configuration changes🕐 40+ MinutesWalkthroughs
User Description
Adds Adobe Firefly Services as a first-class image-generation provider — a live demonstration that the architecture is built for it.
The point
The domain depends only on
ImageGeneratorPort. Adopting Firefly is one new adapter + one line at the composition root — the use case, compliance, export, and UI never change. That's the "Firefly is one adapter away" claim, made real.What's here
FireflyImageGenerator(packages/CreativeGeneration): Adobe IMS client-credentials auth → Firefly v3generate→ fetch the presigned asset → cover-fit to the exact ratio. Degrades to the injected fallback on any failure, same pattern as the Imagen/OpenRouter adapters.apps/api/server/lib/pipeline.ts: selectable via the model picker or?model=firefly; falls through to Imagen → OpenRouter → procedural when Firefly is unavailable or credentials are absent.fireflyBackgroundSourceflows to the run report and a FIREFLY badge in the review grid (so a Firefly run is visible, honest, and never silently a fallback).FIREFLY_CLIENT_ID/FIREFLY_CLIENT_SECRETdocumented in.env.example; README updated.Quality
AI Description
Diagram
High-Level Assessment
The following are alternative approaches to this PR:
1. Cache IMS access tokens in FireflyImageGenerator
2. Share a common cover-fit utility across adapters
3. Use an official Adobe Firefly/IMS SDK (if available) instead of raw fetch
Recommendation: The PR’s approach (a dedicated Firefly adapter behind ImageGeneratorPort plus minimal composition-root wiring) is the right architectural fit for a ports-and-adapters system and keeps the domain/UI stable. The main worthwhile follow-up is token caching to reduce repeated IMS auth calls during large runs; the other alternatives are optional refinements rather than better core strategies.
File Changes
Enhancement (7)
Tests (3)
Documentation (1)
Other (1)