feat(provider): add Xiaomi Token Plan providers for CN, SGP, and AMS#1556
feat(provider): add Xiaomi Token Plan providers for CN, SGP, and AMS#1556
Conversation
📝 WalkthroughWalkthroughThis change adds support for three region-specific Xiaomi Token Plan providers (CN, SGP, AMS) by registering them in the provider configuration and registry. Additionally, the model provider settings UI sidebar width increases from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/presenter/llmProviderPresenter/providerRegistry.ts`:
- Around line 401-426: The Xiaomi token-plan entries (keys like
'xiaomi-token-plan-cn', 'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams')
created via createDefinition({...CHINESE_SUMMARY_OPENAI, modelSource:
'provider-db', ...}) include inert fields providerDbSourceId and
providerDbGroup; remove those two fields from each Xiaomi token-plan
createDefinition call so the objects only include CHINESE_SUMMARY_OPENAI and
modelSource: 'provider-db' (this aligns with mapProviderDbModels resolution by
this.provider.id and the fact providerDbSourceId is only used by the 'config-db'
strategy).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9aa7c86c-0abd-4e24-ab48-a1c98ccf62ef
📒 Files selected for processing (3)
src/main/presenter/configPresenter/providers.tssrc/main/presenter/llmProviderPresenter/providerRegistry.tssrc/renderer/settings/components/ModelProviderSettings.vue
| [ | ||
| 'xiaomi-token-plan-cn', | ||
| createDefinition({ | ||
| ...CHINESE_SUMMARY_OPENAI, | ||
| modelSource: 'provider-db', | ||
| providerDbSourceId: 'xiaomi-token-plan-cn', | ||
| providerDbGroup: 'token-plan' | ||
| }) | ||
| ], | ||
| [ | ||
| 'xiaomi-token-plan-sgp', | ||
| createDefinition({ | ||
| ...CHINESE_SUMMARY_OPENAI, | ||
| modelSource: 'provider-db', | ||
| providerDbSourceId: 'xiaomi-token-plan-sgp', | ||
| providerDbGroup: 'token-plan' | ||
| }) | ||
| ], | ||
| [ | ||
| 'xiaomi-token-plan-ams', | ||
| createDefinition({ | ||
| ...CHINESE_SUMMARY_OPENAI, | ||
| modelSource: 'provider-db', | ||
| providerDbSourceId: 'xiaomi-token-plan-ams', | ||
| providerDbGroup: 'token-plan' | ||
| }) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 3 -P 'providerDbSourceId|providerDbGroup|getProvider\s*\(' src/main/presenterRepository: ThinkInAIXYZ/deepchat
Length of output: 11036
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check full implementation of mapProviderDbModels and how providerDbGroup is used
rg -A 15 'mapProviderDbModels\(group' src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.ts
# Also check if there's any filtering logic that uses providerDbGroup
echo "=== Checking for providerDbGroup filtering logic ==="
rg -B 2 -A 5 'providerDbGroup' src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.tsRepository: ThinkInAIXYZ/deepchat
Length of output: 1187
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find resolveProviderId implementation
rg -B 2 -A 10 'function resolveProviderId|const resolveProviderId|export.*resolveProviderId' src/
# Also check where modelCapabilities is imported from
rg -B 2 -A 2 'import.*modelCapabilities|from.*modelCapabilities' src/main/presenter/llmProviderPresenter/providers/aiSdkProvider.tsRepository: ThinkInAIXYZ/deepchat
Length of output: 796
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find PROVIDER_ID_ALIASES definition
rg -B 2 -A 30 'PROVIDER_ID_ALIASES' src/main/presenter/configPresenter/providerId.tsRepository: ThinkInAIXYZ/deepchat
Length of output: 562
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find where provider DB is loaded from and check its structure
rg -B 2 -A 10 'getDb\(\)|this.db|const db' src/main/presenter/configPresenter/providerDbLoader.ts | head -100
# Also search for xiaomi in the codebase to see if there are any mappings
echo "=== Checking for xiaomi references ==="
rg 'xiaomi' src/main/presenter --no-heading -iRepository: ThinkInAIXYZ/deepchat
Length of output: 4917
Remove unused providerDbSourceId and providerDbGroup fields from Xiaomi token plan entries.
The providerDbGroup parameter passed to mapProviderDbModels() is unused—the function resolves models purely by this.provider.id. Similarly, providerDbSourceId is only consumed in the config-db strategy path, not provider-db. Since these Xiaomi entries use modelSource: 'provider-db', both fields are inert and should be removed to avoid misleading future maintainers.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/presenter/llmProviderPresenter/providerRegistry.ts` around lines 401
- 426, The Xiaomi token-plan entries (keys like 'xiaomi-token-plan-cn',
'xiaomi-token-plan-sgp', 'xiaomi-token-plan-ams') created via
createDefinition({...CHINESE_SUMMARY_OPENAI, modelSource: 'provider-db', ...})
include inert fields providerDbSourceId and providerDbGroup; remove those two
fields from each Xiaomi token-plan createDefinition call so the objects only
include CHINESE_SUMMARY_OPENAI and modelSource: 'provider-db' (this aligns with
mapProviderDbModels resolution by this.provider.id and the fact
providerDbSourceId is only used by the 'config-db' strategy).
Summary by CodeRabbit
New Features
UI Improvements