@@ -19,14 +19,31 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
1919 capabilities : [ ] ,
2020 } ) ;
2121
22- // Sort models by created_at date (newest first)
22+ // List of model names to pin at the top
23+ const pinnedModelNames = [
24+ "@cf/meta/llama-3.3-70b-instruct-fp8-fast" ,
25+ "@cf/meta/llama-3.1-8b-instruct-fast" ,
26+ ] ;
27+
28+ // Sort models by pinned status first, then by created_at date
2329 const sortedModels = useMemo ( ( ) => {
2430 return [ ...models ] . sort ( ( a , b ) => {
25- // Default dates if created_at is not available
31+ // First check if either model is pinned
32+ const isPinnedA = pinnedModelNames . includes ( a . name ) ;
33+ const isPinnedB = pinnedModelNames . includes ( b . name ) ;
34+
35+ // If pinned status differs, prioritize pinned models
36+ if ( isPinnedA && ! isPinnedB ) return - 1 ;
37+ if ( ! isPinnedA && isPinnedB ) return 1 ;
38+
39+ // If both are pinned, sort by position in pinnedModelNames array (for manual ordering)
40+ if ( isPinnedA && isPinnedB ) {
41+ return pinnedModelNames . indexOf ( a . name ) - pinnedModelNames . indexOf ( b . name ) ;
42+ }
43+
44+ // If neither is pinned, sort by created_at date (newest first)
2645 const dateA = a . created_at ? new Date ( a . created_at ) : new Date ( 0 ) ;
2746 const dateB = b . created_at ? new Date ( b . created_at ) : new Date ( 0 ) ;
28-
29- // Sort in descending order (newest first)
3047 return dateB . getTime ( ) - dateA . getTime ( ) ;
3148 } ) ;
3249 } , [ models ] ) ;
0 commit comments