The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import { AI_MODEL_TIERS, type AiModelTier } from 'twenty-shared/ai';
// lower rung first at equal distance so a missing rung borrows the cheaper side
export const getAiModelTiersByDistance = (tier: AiModelTier): AiModelTier[] => {
const tierIndex = AI_MODEL_TIERS.indexOf(tier);
const distanceOf = (candidate: AiModelTier) =>
Math.abs(AI_MODEL_TIERS.indexOf(candidate) - tierIndex);
return [...AI_MODEL_TIERS].sort(
(first, second) =>
distanceOf(first) - distanceOf(second) ||
AI_MODEL_TIERS.indexOf(first) - AI_MODEL_TIERS.indexOf(second),
);
};