Repository navigation
fix: support provider-specific verify payload for per-model verify - #17522
Conversation
📝 WalkthroughWalkthroughProvider configuration now supplies optional verification transforms through draft and saved instance cards. ChangesProvider verification transform
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ProviderInstanceCard
participant ModeCard
participant ModelsSection
participant VerifyEndpoint
ProviderInstanceCard->>ModeCard: pass providerConfig.verifyTransform
ModeCard->>ModelsSection: pass verifyTransform
ModelsSection->>ModelsSection: invoke useModelVerify
ModelsSection->>VerifyEndpoint: send transformed per-model verification payload
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web/src/pages/user-setting/setting-model/instance-card/models-section/interface.ts (1)
70-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReuse the shared
VerifyTransformcontract.These duplicate callback definitions can drift from the card-level contract.
web/src/pages/user-setting/setting-model/instance-card/models-section/interface.ts#L70-L75: import and useVerifyTransform.web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts#L408-L413: use the same imported alias forUseModelVerifyArgs.As per coding guidelines, “Reduce public surface area” and keep refactors centered on the owning abstraction.
Proposed refactor
+import type { VerifyTransform } from '../interface'; - verifyTransform?: (values: Record<string, any>) => { - apiKey: string | object | Record<string, any>; - baseUrl?: string; - region?: string; - modelInfo?: IModelInfo[]; - }; + verifyTransform?: VerifyTransform;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/pages/user-setting/setting-model/instance-card/models-section/interface.ts` around lines 70 - 75, Replace the duplicate verifyTransform callback in web/src/pages/user-setting/setting-model/instance-card/models-section/interface.ts:70-75 with the shared VerifyTransform contract, importing it from its owning abstraction. Update web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts:408-413 so UseModelVerifyArgs also references that same imported VerifyTransform alias; no other sites require changes.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@web/src/pages/user-setting/setting-model/instance-card/models-section/interface.ts`:
- Around line 70-75: Replace the duplicate verifyTransform callback in
web/src/pages/user-setting/setting-model/instance-card/models-section/interface.ts:70-75
with the shared VerifyTransform contract, importing it from its owning
abstraction. Update
web/src/pages/user-setting/setting-model/instance-card/models-section/hooks.ts:408-413
so UseModelVerifyArgs also references that same imported VerifyTransform alias;
no other sites require changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f14a6728-5713-4294-9913-0ff94654cb23
📒 Files selected for processing (8)
web/src/pages/user-setting/setting-model/instance-card/components/draft-mode-card.tsxweb/src/pages/user-setting/setting-model/instance-card/components/saved-mode-card.tsxweb/src/pages/user-setting/setting-model/instance-card/hooks.tsxweb/src/pages/user-setting/setting-model/instance-card/interface.tsweb/src/pages/user-setting/setting-model/instance-card/models-section/hooks.tsweb/src/pages/user-setting/setting-model/instance-card/models-section/index.tsxweb/src/pages/user-setting/setting-model/instance-card/models-section/interface.tsweb/src/pages/user-setting/setting-model/instance-card/provider-instance-card.tsx
💤 Files with no reviewable changes (1)
- web/src/pages/user-setting/setting-model/instance-card/hooks.tsx
wangq8
left a comment
There was a problem hiding this comment.
Thanks for this PR! The per-model verify flow definitely needed provider-specific credential mapping — this correctly mirrors the existing verifyTransform pattern already used in useVerifyProvider for card-level verify. Good stuff.
A few observations:
1. VerifyTransform type duplication
The type is defined as a named export in instance-card/interface.ts and inlined again in models-section/interface.ts. Consider importing the type from instance-card/interface.ts into the models-section interface to keep the single source of truth. If there are dependency-order concerns preventing this, a comment noting why would help future readers.
2. apiKey as any cast
api_key: apiKey as any — I see the comment explaining why (PaddleOCR produces a nested object where the service signature types string). This is pragmatic and matches the existing pattern in useVerifyProvider. Might be worth a follow-up to make the service type accept string | object properly, but not blocking here.
3. instanceName dependency removal
The removal of instanceName from the useInstanceSaveState dependency array in hooks.tsx is a separate cleanup. As long as instanceName is genuinely unused inside that effect, LGTM — but worth double-checking that the effect body doesn't reference it.
4. Region support
Nice that region is now forwarded in the per-model verify payload — the original handleVerify didn't include it at all, so this is a bonus fix alongside the main change.
5. Tests
No test coverage included. Given that useModelVerify now has a branching code path (verifyTransform vs resolveCreds), a unit test covering both paths would add confidence. Non-blocking but worth a follow-up.
Overall the threading is clean — providerConfig.verifyTransform → DraftModeCard/SavedModeCard → ModelsSection → useModelVerify all lines up. LGTM.
Summary
fix: support provider-specific verify payload for per-model verify