Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
# CI runs the full lint, type-check and audit gate on every PR, so it stays the backstop.
set -e

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

# git passes one "<local ref> <local sha> <remote ref> <remote sha>" line per pushed ref.
zero=0000000000000000000000000000000000000000
head=$(git rev-parse HEAD)
Expand All @@ -25,6 +42,7 @@ if [ -z "$base" ]; then
echo "pre-push: origin/staging not found, running the full lint and type-check"
bun run lint:check
bun run type-check
check_generated_artifacts
exit 0
fi

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

# A stale generated artifact would only fail CI's check:audits. Generators read the working tree,
# so the result describes the pushed commit only when the tree is that commit; with uncommitted or
# untracked files the check is left to CI rather than judging (or blocking) unrelated work.
if git diff --quiet HEAD && [ -z "$(git ls-files --others --exclude-standard)" ]; then
bun run generate >/dev/null
if ! git diff --quiet; then
echo "pre-push: generated artifacts were stale and have been regenerated:"
git diff --name-only
echo "pre-push: commit them and push again."
exit 1
fi
else
echo "pre-push: uncommitted changes; leaving generated-artifact freshness to CI"
fi
check_generated_artifacts
33 changes: 21 additions & 12 deletions apps/sim/app/(landing)/models/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ export interface CatalogProvider {
providerCapabilityTags: string[]
modelCount: number
models: CatalogModel[]
/** The models that still accept requests; every recommendation reads these, never `models`. */
currentModels: CatalogModel[]
featuredModels: CatalogModel[]
searchText: string
}
Expand Down Expand Up @@ -438,8 +440,11 @@ function buildBestForLine(model: {
pricing: PricingInfo
capabilities: ModelCapabilities
contextWindow: number | null
retired: boolean
}): string | null {
const { pricing, capabilities, contextWindow } = model
const { pricing, capabilities, contextWindow, retired } = model

if (retired) return null

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

const featuredModels = [...models].sort(compareModelsByRelevance).slice(0, 6)
const currentModels = models.filter((model) => !model.retired)
const featuredModels = [...currentModels].sort(compareModelsByRelevance).slice(0, 6)
const naming = PROVIDER_MODEL_FAMILIES[provider.id]
const modelFamily = naming?.family ?? providerDisplayName

Expand All @@ -588,6 +595,7 @@ const rawProviders = Object.values(PROVIDER_DEFINITIONS).map((provider) => {
providerCapabilityTags,
modelCount: models.length,
models,
currentModels,
featuredModels,
searchText: [
provider.name,
Expand Down Expand Up @@ -697,7 +705,7 @@ export function getRelatedModels(targetModel: CatalogModel, limit = 6): CatalogM

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

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

const toolUseModels = provider.models.filter(
const toolUseModels = provider.currentModels.filter(
(m) =>
m.capabilities.toolUsageControl !== undefined ||
provider.providerCapabilityTags.includes('Tool Use')
)
const namedModels = provider.currentModels.slice(0, 6)

const faqs: CatalogFaq[] = [
{
question: `What ${provider.name} models are available in Sim?`,
answer: `Sim currently tracks ${provider.modelCount} ${provider.name} model${provider.modelCount === 1 ? '' : 's'} including ${provider.models
.slice(0, 6)
answer: `Sim currently supports ${provider.currentModels.length} ${provider.name} model${provider.currentModels.length === 1 ? '' : 's'} including ${namedModels
.map((model) => model.displayName)
.join(', ')}${provider.modelCount > 6 ? ', and more' : ''}.`,
.join(', ')}${provider.currentModels.length > namedModels.length ? ', and more' : ''}.`,
},
{
question: `What is the default ${provider.name} model in Sim?`,
Expand Down Expand Up @@ -770,7 +778,7 @@ export function buildProviderFaqs(provider: CatalogProvider): CatalogFaq[] {
faqs.push({
question: `Which ${provider.name} models support tool use and function calling in Sim?`,
answer:
toolUseModels.length === provider.modelCount
toolUseModels.length === provider.currentModels.length
? `All ${provider.name} models in Sim support tool use and function calling, allowing agents to invoke external APIs, query databases, and run custom actions.`
: `${toolUseModels
.slice(0, 5)
Expand Down Expand Up @@ -880,9 +888,10 @@ export function buildModelCapabilityFacts(model: CatalogModel): CapabilityFact[]
]
}

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

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

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