Repository navigation
Add GLM 5 and MiniMax M2.5 model support with tier-based rate limiting - #629
Conversation
- Update PageSpace tier models: Standard (glm-4.7), Pro (glm-5) - Add GLM 5 and MiniMax M2.5 to OpenRouter and direct providers - Add pricing data for new models in ai-monitoring.ts - Add context window data for new models (GLM 5: 200k, MiniMax M2.5: 1M) - Update ai-context-calculator with GLM 5 and MiniMax patterns - Refactor rate limiting to use tier-based lookup via getPageSpaceModelTier() instead of hardcoded model names - future model changes only need PAGESPACE_MODEL_ALIASES update - Add MiniMax M2.5 to vision-capable models - Add migration to update existing users to new tier models - Add comprehensive tests for ai-providers-config functions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughThis PR updates PageSpace model tiers and configurations across the application. It introduces glm-5 as a Pro tier model, migrates references from glm-4.5-air (Standard) to glm-4.7, adds new models (glm-5, MiniMax M2.5) to pricing and context mappings, updates rate-limiting to use tier-based logic, and includes a database migration script to align existing user data with the new tier structure. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/lib/ai/core/provider-factory.ts (1)
90-95:⚠️ Potential issue | 🟡 MinorStale comment references old model alias.
Line 92 still says
'standard' -> 'glm-4.5-air'but the alias now resolves to'glm-4.7'.📝 Fix the comment
- // Resolve model aliases for PageSpace provider (e.g., 'standard' -> 'glm-4.5-air') + // Resolve model aliases for PageSpace provider (e.g., 'standard' -> 'glm-4.7')
🤖 Fix all issues with AI agents
In `@packages/db/src/schema/auth.ts`:
- Line 24: The schema default change on the column symbol currentAiModel (in
auth.ts) must be captured by an auto-generated DDL migration: run `pnpm
db:generate` to produce the migration that records the default change
(glm-4.5-air -> glm-4.7), add that generated migration file to the commit, and
remove or revert any manual schema edits so that only the auto-generated
migration (not a hand-edited change) introduces the default update; ensure the
existing manual data migration (0083) remains only for data changes and not the
column-default DDL.
🧹 Nitpick comments (4)
packages/db/drizzle/0083_migrate_pagespace_model_tiers.sql (1)
8-18: Migration logic and ordering look correct.The execution order (Pro before Standard) correctly prevents double-migration. The WHERE clauses are appropriately scoped to
currentAiProvider = 'pagespace'only.One minor consideration: there's no explicit transaction boundary. If the migration runner doesn't auto-wrap each file in a transaction, a failure between Step 1 and Step 2 could leave the database in an inconsistent state.
🛡️ Suggested: wrap in a transaction
+BEGIN; + -- Step 1: Migrate Pro users from glm-4.7 to glm-5 UPDATE users SET "currentAiModel" = 'glm-5' WHERE "currentAiProvider" = 'pagespace' AND "currentAiModel" = 'glm-4.7'; -- Step 2: Migrate Standard users from glm-4.5-air to glm-4.7 UPDATE users SET "currentAiModel" = 'glm-4.7' WHERE "currentAiProvider" = 'pagespace' AND "currentAiModel" = 'glm-4.5-air'; + +COMMIT;apps/web/src/lib/ai/core/ai-providers-config.ts (3)
33-48: Well-structured reverse lookup for tier resolution.The function is clean and the case-insensitive matching is a good touch. The
as 'standard' | 'pro'cast is safe given the current alias map.One minor resilience note: if a third tier is ever added to
PAGESPACE_MODEL_ALIASES, the return type and cast would need a manual update. Consider deriving the tier type from the alias keys to keep them in sync:♻️ Optional: derive tier type from alias keys
+type PageSpaceTier = keyof typeof PAGESPACE_MODEL_ALIASES; + -export function getPageSpaceModelTier(model: string): 'standard' | 'pro' | null { +export function getPageSpaceModelTier(model: string): PageSpaceTier | null { const modelLower = model.toLowerCase(); for (const [tier, tierModel] of Object.entries(PAGESPACE_MODEL_ALIASES)) { if (tierModel.toLowerCase() === modelLower) { - return tier as 'standard' | 'pro'; + return tier as PageSpaceTier; } } return null; }Note: This would require removing the
Record<string, string>type annotation onPAGESPACE_MODEL_ALIASES(keeping onlyas const) sokeyof typeofyields literal key types instead ofstring. That's a broader change, so feel free to defer.
11-14:Record<string, string>widens away theas constnarrowing.The explicit type annotation
Record<string, string>makes theas constassertion a no-op — keys and values are widened tostring. This is pre-existing, but it's the root reasongetPageSpaceModelTierneeds theascast on Line 44. If you ever want to derive types from this map (as suggested above), you'd drop the annotation:-export const PAGESPACE_MODEL_ALIASES: Record<string, string> = { +export const PAGESPACE_MODEL_ALIASES = { standard: 'glm-4.7', pro: 'glm-5', } as const;This is a low-priority cleanup — no functional impact.
446-454: Consider usinggetPageSpaceModelTierhere for consistency.The rate-limit middleware was refactored to use
getPageSpaceModelTierinstead of hardcoded model IDs, butgetUserFacingModelNamestill compares against literal strings'glm-5'and'glm-4.7'. If the alias mapping changes, this function would also need a manual update.♻️ Optional: use tier lookup for consistency
if (provider === 'pagespace') { const resolvedModel = resolvePageSpaceModel(model); - if (resolvedModel === 'glm-5') { + const tier = getPageSpaceModelTier(resolvedModel); + if (tier === 'pro') { return 'PageSpace Pro'; } - if (resolvedModel === 'glm-4.7') { - return 'PageSpace Standard'; - } // Any other PageSpace model defaults to Standard return 'PageSpace Standard'; }
Update comment to reflect correct model alias: 'standard' -> 'glm-4.7' (was incorrectly 'glm-4.5-air') Addresses CodeRabbit review feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addressing CodeRabbit Review FeedbackFixed: Stale comment in provider-factory.tsUpdated the comment at line 92 to correctly reference Commit: 35dcff2 Regarding Nitpick SuggestionsThe nitpick suggestions (transaction boundary, type derivation, etc.) are good ideas for future refactoring but are out of scope for this PR which focuses on model tier updates. The current implementation is correct and functional. |
- Added 0084_update_default_ai_model.sql to update column default - Updated migration journal to include both data (0083) and DDL (0084) migrations - Added snapshots for migration tracking This addresses the CodeRabbit review feedback about running pnpm db:generate to capture the schema default change from 'glm-4.5-air' to 'glm-4.7'. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixed: DDL Migration for Default AI Model ChangeRan
Commit: 73798bd This addresses the CodeRabbit review feedback at |
Summary
glm-4.7), Pro (glm-5)Changes
Provider Configuration
PAGESPACE_MODEL_ALIASES: standard → glm-4.7, pro → glm-5z-ai/glm-5andminimax/minimax-m2.5to OpenRouterglm-5andMiniMax-M2.5to direct providersgetUserFacingModelName()andgetDefaultModel()Rate Limiting (Refactored)
getPageSpaceModelTier(model)function for reverse alias lookupPAGESPACE_MODEL_ALIASESMonitoring & Pricing
ai-context-calculator.tswith GLM 5 and MiniMax patternsDatabase
0083_migrate_pagespace_model_tiers.sqlupdates existing usersglm-4.7Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests
Chores