Skip to content

Commit 74e9770

Browse files
committed
fix(models): keep retired models out of catalog recommendations and run the pre-push artifact check without origin/staging
1 parent 29b63df commit 74e9770

2 files changed

Lines changed: 40 additions & 26 deletions

File tree

‎.husky/pre-push‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
# CI runs the full lint, type-check and audit gate on every PR, so it stays the backstop.
66
set -e
77

8+
# A stale generated artifact would only fail CI's check:audits. Generators read the working tree,
9+
# so the result describes the pushed commit only when the tree is that commit; with uncommitted or
10+
# untracked files the check is left to CI rather than judging (or blocking) unrelated work.
11+
check_generated_artifacts() {
12+
if git diff --quiet HEAD && [ -z "$(git ls-files --others --exclude-standard)" ]; then
13+
bun run generate >/dev/null
14+
if ! git diff --quiet; then
15+
echo "pre-push: generated artifacts were stale and have been regenerated:"
16+
git diff --name-only
17+
echo "pre-push: commit them and push again."
18+
exit 1
19+
fi
20+
else
21+
echo "pre-push: uncommitted changes; leaving generated-artifact freshness to CI"
22+
fi
23+
}
24+
825
# git passes one "<local ref> <local sha> <remote ref> <remote sha>" line per pushed ref.
926
zero=0000000000000000000000000000000000000000
1027
head=$(git rev-parse HEAD)
@@ -25,6 +42,7 @@ if [ -z "$base" ]; then
2542
echo "pre-push: origin/staging not found, running the full lint and type-check"
2643
bun run lint:check
2744
bun run type-check
45+
check_generated_artifacts
2846
exit 0
2947
fi
3048

@@ -44,17 +62,4 @@ if printf '%s\n' "$changed" | grep -qE '^scripts/'; then
4462
fi
4563
TURBO_SCM_BASE="$base" bunx turbo run type-check --affected --output-logs=errors-only
4664

47-
# A stale generated artifact would only fail CI's check:audits. Generators read the working tree,
48-
# so the result describes the pushed commit only when the tree is that commit; with uncommitted or
49-
# untracked files the check is left to CI rather than judging (or blocking) unrelated work.
50-
if git diff --quiet HEAD && [ -z "$(git ls-files --others --exclude-standard)" ]; then
51-
bun run generate >/dev/null
52-
if ! git diff --quiet; then
53-
echo "pre-push: generated artifacts were stale and have been regenerated:"
54-
git diff --name-only
55-
echo "pre-push: commit them and push again."
56-
exit 1
57-
fi
58-
else
59-
echo "pre-push: uncommitted changes; leaving generated-artifact freshness to CI"
60-
fi
65+
check_generated_artifacts

‎apps/sim/app/(landing)/models/utils.ts‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ export interface CatalogProvider {
172172
providerCapabilityTags: string[]
173173
modelCount: number
174174
models: CatalogModel[]
175+
/** The models that still accept requests; every recommendation reads these, never `models`. */
176+
currentModels: CatalogModel[]
175177
featuredModels: CatalogModel[]
176178
searchText: string
177179
}
@@ -438,8 +440,11 @@ function buildBestForLine(model: {
438440
pricing: PricingInfo
439441
capabilities: ModelCapabilities
440442
contextWindow: number | null
443+
retired: boolean
441444
}): string | null {
442-
const { pricing, capabilities, contextWindow } = model
445+
const { pricing, capabilities, contextWindow, retired } = model
446+
447+
if (retired) return null
443448

444449
if (capabilities.reasoningEffort || capabilities.thinking) {
445450
return 'Best for reasoning-heavy tasks that need more deliberate model control.'
@@ -512,6 +517,7 @@ const rawProviders = Object.values(PROVIDER_DEFINITIONS).map((provider) => {
512517
pricing: model.pricing,
513518
capabilities: mergedCapabilities,
514519
contextWindow: model.contextWindow ?? null,
520+
retired,
515521
})
516522
const displayName = formatModelDisplayName(provider.id, model.id)
517523
const modelSlug = slugify(shortId)
@@ -563,7 +569,8 @@ const rawProviders = Object.values(PROVIDER_DEFINITIONS).map((provider) => {
563569
models.find((model) => model.id === provider.defaultModel)?.displayName ||
564570
(provider.defaultModel ? formatModelDisplayName(provider.id, provider.defaultModel) : 'Dynamic')
565571

566-
const featuredModels = [...models].sort(compareModelsByRelevance).slice(0, 6)
572+
const currentModels = models.filter((model) => !model.retired)
573+
const featuredModels = [...currentModels].sort(compareModelsByRelevance).slice(0, 6)
567574
const naming = PROVIDER_MODEL_FAMILIES[provider.id]
568575
const modelFamily = naming?.family ?? providerDisplayName
569576

@@ -588,6 +595,7 @@ const rawProviders = Object.values(PROVIDER_DEFINITIONS).map((provider) => {
588595
providerCapabilityTags,
589596
modelCount: models.length,
590597
models,
598+
currentModels,
591599
featuredModels,
592600
searchText: [
593601
provider.name,
@@ -697,7 +705,7 @@ export function getRelatedModels(targetModel: CatalogModel, limit = 6): CatalogM
697705

698706
const targetTokens = new Set(tokenizeModelName(stripTechnicalSuffixes(targetModel.shortId)))
699707

700-
const scored = provider.models.reduce<Array<{ model: CatalogModel; score: number }>>(
708+
const scored = provider.currentModels.reduce<Array<{ model: CatalogModel; score: number }>>(
701709
(acc, model) => {
702710
if (model.id === targetModel.id) {
703711
return acc
@@ -728,19 +736,19 @@ export function buildProviderFaqs(provider: CatalogProvider): CatalogFaq[] {
728736
const cheapestModel = getCheapestProviderModel(provider)
729737
const largestContextModel = getLargestContextProviderModel(provider)
730738

731-
const toolUseModels = provider.models.filter(
739+
const toolUseModels = provider.currentModels.filter(
732740
(m) =>
733741
m.capabilities.toolUsageControl !== undefined ||
734742
provider.providerCapabilityTags.includes('Tool Use')
735743
)
744+
const namedModels = provider.currentModels.slice(0, 6)
736745

737746
const faqs: CatalogFaq[] = [
738747
{
739748
question: `What ${provider.name} models are available in Sim?`,
740-
answer: `Sim currently tracks ${provider.modelCount} ${provider.name} model${provider.modelCount === 1 ? '' : 's'} including ${provider.models
741-
.slice(0, 6)
749+
answer: `Sim currently tracks ${provider.modelCount} ${provider.name} model${provider.modelCount === 1 ? '' : 's'} including ${namedModels
742750
.map((model) => model.displayName)
743-
.join(', ')}${provider.modelCount > 6 ? ', and more' : ''}.`,
751+
.join(', ')}${provider.modelCount > namedModels.length ? ', and more' : ''}.`,
744752
},
745753
{
746754
question: `What is the default ${provider.name} model in Sim?`,
@@ -770,7 +778,7 @@ export function buildProviderFaqs(provider: CatalogProvider): CatalogFaq[] {
770778
faqs.push({
771779
question: `Which ${provider.name} models support tool use and function calling in Sim?`,
772780
answer:
773-
toolUseModels.length === provider.modelCount
781+
toolUseModels.length === provider.currentModels.length
774782
? `All ${provider.name} models in Sim support tool use and function calling, allowing agents to invoke external APIs, query databases, and run custom actions.`
775783
: `${toolUseModels
776784
.slice(0, 5)
@@ -880,9 +888,10 @@ export function buildModelCapabilityFacts(model: CatalogModel): CapabilityFact[]
880888
]
881889
}
882890

891+
/** The provider's current model with the lowest input price. */
883892
export function getCheapestProviderModel(provider: CatalogProvider): CatalogModel | null {
884-
if (provider.models.length === 0) return null
885-
return provider.models.reduce((min, m) => (m.pricing.input < min.pricing.input ? m : min))
893+
if (provider.currentModels.length === 0) return null
894+
return provider.currentModels.reduce((min, m) => (m.pricing.input < min.pricing.input ? m : min))
886895
}
887896

888897
/**
@@ -899,12 +908,12 @@ export function compareByContextWindow(a: CatalogModel, b: CatalogModel): number
899908
}
900909

901910
/**
902-
* The provider's largest-context model that is not retired. Ties go to the first model in catalog
911+
* The provider's largest-context current model. Ties go to the first model in catalog
903912
* order, so the answer names the provider's headline model rather than a smaller sibling with the
904913
* same window.
905914
*/
906915
export function getLargestContextProviderModel(provider: CatalogProvider): CatalogModel | null {
907-
const candidates = provider.models.filter((model) => !model.retired && model.contextWindow)
916+
const candidates = provider.currentModels.filter((model) => model.contextWindow)
908917
if (candidates.length === 0) return null
909918
return candidates.reduce((max, model) =>
910919
(model.contextWindow ?? 0) > (max.contextWindow ?? 0) ? model : max

0 commit comments

Comments
 (0)