Skip to content

Commit

Permalink
chore: do not allow 4o models in default provider (except mini) (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
geclos authored Oct 24, 2024
1 parent 8036d2b commit 48358b8
Show file tree
Hide file tree
Showing 10 changed files with 3,055 additions and 17 deletions.
23 changes: 19 additions & 4 deletions apps/web/src/components/EditorHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react'
import { omit } from 'lodash-es'

import { ConversationMetadata } from '@latitude-data/compiler'
import {
Expand All @@ -7,6 +8,7 @@ import {
ProviderApiKey,
Providers,
} from '@latitude-data/core/browser'
import { DEFAULT_PROVIDER_UNSUPPORTED_MODELS } from '@latitude-data/core/services/ai/providers/models/index'
import {
AppLocalStorage,
DropdownMenu,
Expand All @@ -22,16 +24,26 @@ import { ROUTES } from '$/services/routes'
import useProviderApiKeys from '$/stores/providerApiKeys'
import Link from 'next/link'

function useModelsOptions({ provider }: { provider: Providers | undefined }) {
function useModelsOptions({
provider,
isDefaultProvider = false,
}: {
provider: Providers | undefined
isDefaultProvider?: boolean
}) {
return useMemo(() => {
const models = provider ? PROVIDER_MODELS[provider] : null
let models = provider ? PROVIDER_MODELS[provider] : null
if (!models) return []

if (isDefaultProvider) {
models = omit(models, DEFAULT_PROVIDER_UNSUPPORTED_MODELS)
}

return Object.keys(models).map((model) => ({
label: model,
value: model,
}))
}, [provider])
}, [provider, isDefaultProvider])
}

type PromptMeta = { providerName: string; model: string }
Expand Down Expand Up @@ -131,10 +143,13 @@ export default function EditorHeader({
value: apiKey.name,
}))
}, [providerApiKeys])
const isDefaultProvider =
selectedProvider === envClient.NEXT_PUBLIC_DEFAULT_PROJECT_ID
const modelOptions = useModelsOptions({
provider: selectedProvider
? providersByName[selectedProvider]?.provider
: undefined,
isDefaultProvider,
})

useEffect(() => {
Expand Down Expand Up @@ -263,7 +278,7 @@ export default function EditorHeader({
onChange={onModelChange}
/>
</FormFieldGroup>
{selectedProvider === envClient.NEXT_PUBLIC_DEFAULT_PROJECT_ID && (
{isDefaultProvider && (
<div>
{freeRunsCount !== undefined ? (
<Text.H6 color='foregroundMuted'>
Expand Down
1 change: 1 addition & 0 deletions packages/core/drizzle/0081_cultured_vance_astro.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TYPE "latitude"."run_error_code_enum" ADD VALUE 'default_provider_invalid_model_error';
Loading

0 comments on commit 48358b8

Please sign in to comment.