From 9795510071a4ecee28599721978d3b92d506eb66 Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Sat, 28 Jun 2025 17:18:32 +0000 Subject: [PATCH] feat(pricing): improve model sorting and add Gemini 2.5 Pro to model selection --- .../app/(dashboard)/model-pricing/page.tsx | 16 ++++++++- .../thread/chat-input/_use-model-selection.ts | 33 ++++++++++--------- .../thread/chat-input/model-selector.tsx | 22 ------------- 3 files changed, 32 insertions(+), 39 deletions(-) diff --git a/frontend/src/app/(dashboard)/model-pricing/page.tsx b/frontend/src/app/(dashboard)/model-pricing/page.tsx index 2f7ebbd8..8ba56a62 100644 --- a/frontend/src/app/(dashboard)/model-pricing/page.tsx +++ b/frontend/src/app/(dashboard)/model-pricing/page.tsx @@ -168,8 +168,22 @@ export default function PricingPage() { ...v, display_name: allModels.find((m) => m.id === v.short_name)?.label, priority: allModels.find((m) => m.id === v.short_name)?.priority, + requiresSubscription: allModels.find((m) => m.id === v.short_name)?.requiresSubscription, })) - .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)); + .sort((a, b) => { + // First by free/premium status (premium first) + if (a.requiresSubscription !== b.requiresSubscription) { + return a.requiresSubscription ? -1 : 1; + } + + // Then by priority (higher first) + if ((a.priority ?? 0) !== (b.priority ?? 0)) { + return (b.priority ?? 0) - (a.priority ?? 0); + } + + // Finally by name (alphabetical) + return (a.display_name ?? a.id).localeCompare(b.display_name ?? b.id); + }); }, [modelsResponse?.models, allModels]); // Find the selected model diff --git a/frontend/src/components/thread/chat-input/_use-model-selection.ts b/frontend/src/components/thread/chat-input/_use-model-selection.ts index 46903d33..3c219f8a 100644 --- a/frontend/src/components/thread/chat-input/_use-model-selection.ts +++ b/frontend/src/components/thread/chat-input/_use-model-selection.ts @@ -37,10 +37,17 @@ export const MODELS = { lowQuality: false, description: 'Claude Sonnet 4 - Anthropic\'s latest and most advanced AI assistant' }, - 'claude-sonnet-3.7': { + 'google/gemini-2.5-pro': { + tier: 'premium', + priority: 100, + recommended: false, + lowQuality: false, + description: 'Gemini Pro 2.5 - Google\'s latest advanced model' + }, + 'sonnet-3.7': { tier: 'premium', priority: 95, - recommended: true, + recommended: false, lowQuality: false, description: 'Claude 3.7 - Anthropic\'s most powerful AI assistant' }, @@ -58,13 +65,6 @@ export const MODELS = { lowQuality: false, description: 'GPT-4.1 - OpenAI\'s most advanced model with enhanced reasoning' }, - 'gemini-2.5-pro': { - tier: 'premium', - priority: 99, - recommended: true, - lowQuality: false, - description: 'Gemini Pro 2.5 - Google\'s latest advanced model' - }, 'claude-3.5': { tier: 'premium', priority: 90, @@ -72,10 +72,10 @@ export const MODELS = { lowQuality: false, description: 'Claude 3.5 - Anthropic\'s balanced model with solid capabilities' }, - 'gemini-flash-2.5:thinking': { + 'gemini-2.5-flash:thinking': { tier: 'premium', priority: 90, - recommended: true, + recommended: false, lowQuality: false, description: 'Gemini Flash 2.5 - Google\'s fast, responsive AI model' }, @@ -100,10 +100,10 @@ export const MODELS = { lowQuality: false, description: 'GPT-4 - OpenAI\'s highly capable model with advanced reasoning' }, - 'deepseek-chat-v3-0324': { + 'deepseek/deepseek-chat-v3-0324': { tier: 'premium', priority: 75, - recommended: true, + recommended: false, lowQuality: false, description: 'DeepSeek Chat - Advanced AI assistant with strong reasoning' }, @@ -325,12 +325,12 @@ export const useModelSelection = () => { // 1. First by free/premium (free first) // 2. Then by priority (higher first) // 3. Finally by name (alphabetical) - return models.sort((a, b) => { + const sortedModels = models.sort((a, b) => { // First by free/premium status if (a.requiresSubscription !== b.requiresSubscription) { - return a.requiresSubscription ? 1 : -1; + return a.requiresSubscription ? -1 : 1; } - + // Then by priority (higher first) if (a.priority !== b.priority) { return b.priority - a.priority; @@ -339,6 +339,7 @@ export const useModelSelection = () => { // Finally by name return a.label.localeCompare(b.label); }); + return sortedModels; }, [modelsData, isLoadingModels, customModels]); // Get filtered list of models the user can access (no additional sorting) diff --git a/frontend/src/components/thread/chat-input/model-selector.tsx b/frontend/src/components/thread/chat-input/model-selector.tsx index ba64c319..5d425538 100644 --- a/frontend/src/components/thread/chat-input/model-selector.tsx +++ b/frontend/src/components/thread/chat-input/model-selector.tsx @@ -705,28 +705,6 @@ export const ModelSelector: React.FC = ({ m.label.toLowerCase().includes(searchQuery.toLowerCase()) || m.id.toLowerCase().includes(searchQuery.toLowerCase()) ) - // Sort to prioritize recommended paid models first - .sort((a, b) => { - const aRecommendedPaid = MODELS[a.id]?.recommended && a.requiresSubscription; - const bRecommendedPaid = MODELS[b.id]?.recommended && b.requiresSubscription; - - if (aRecommendedPaid && !bRecommendedPaid) return -1; - if (!aRecommendedPaid && bRecommendedPaid) return 1; - - // Secondary sorting: recommended free models next - const aRecommended = MODELS[a.id]?.recommended; - const bRecommended = MODELS[b.id]?.recommended; - - if (aRecommended && !bRecommended) return -1; - if (!aRecommended && bRecommended) return 1; - - // Paid models next - if (a.requiresSubscription && !b.requiresSubscription) return -1; - if (!a.requiresSubscription && b.requiresSubscription) return 1; - - // Default to alphabetical order - return a.label.localeCompare(b.label); - }) .map((model, index) => renderModelOption(model, index))} {uniqueModels.length === 0 && (