Repository navigation
fix(web): accept a single API key for Baidu YiYan - #18611
Conversation
The backend now allows a plain YiYan API key instead of an AK/SK pair, so the provider form no longer needs two separate credential fields. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughBaidu YiYan configuration now uses one password ChangesBaidu YiYan API key flow
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change updates the Baidu YiYan provider form to accept a single API key; no actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
wangq8
left a comment
There was a problem hiding this comment.
Thanks for this! The change correctly aligns the frontend with the backend's single access-token support — BaiduYiyanChat / BaiduYiyanEmbed / BaiduYiyanRerank now fall back to access_token when the stored key isn't a JSON object. The core change looks good, and switching the field to Password is a nice security improvement.
One thing I'd like you to double-check — backward compatibility for existing instances.
The PR removes echoTransform entirely. For instances saved in the legacy {"yiyan_ak": ..., "yiyan_sk": ...} JSON format, the generic echo fallback (unwrapApiKey in web/src/pages/user-setting/setting-model/instance-card/hooks.tsx) only recognizes a bare string or a literal api_key key inside the JSON object. For the yiyan_ak shape it returns api_key: ''.
As a result, opening and saving an existing AK/SK instance (e.g. just renaming it or changing base_url) will submit an empty api_key and silently clear the stored credential — the api_key field is hidden via hideWhenInstanceExists and is never re-populated from the legacy shape.
Suggested fix: keep a small echoTransform that maps the legacy object back to the single key, e.g.:
echoTransform: (instance) => {
const obj = parseApiKeyAsObject(instance.api_key);
if (obj && typeof obj.yiyan_ak === 'string') {
return { api_key: obj.yiyan_ak };
}
return { api_key: typeof instance.api_key === 'string' ? instance.api_key : '' };
},(or otherwise handle migration of legacy instances).
Minor / non-blocking: the now-unused i18n keys (addyiyanAK, yiyanAKMessage, addyiyanSK, yiyanSKMessage) remain in the locale files — could be cleaned up in a follow-up.
Otherwise LGTM.
Summary
fix(web): accept a single API key for Baidu YiYan
The backend now allows a plain YiYan API key instead of an AK/SK pair, so the provider form no longer needs two separate credential fields.