:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { useActions, useValues } from 'kea'
import { LemonBanner, Link } from '@posthog/lemon-ui'
import { PROVIDER_SETTINGS_URL } from './ModelPicker'
import { modelPickerLogic } from './modelPickerLogic'
import { providerLabel } from './settings/providerKeyStateUtils'
/** Explains an empty or short model picker on the surfaces that only run on the team's own provider keys. */
export function ByokModelPickerNotice({ forEvaluation = false }: { forEvaluation?: boolean }): JSX.Element | null {
const { byokModelNotice: generativeModelNotice, evaluationModelNotice } = useValues(modelPickerLogic)
const byokModelNotice = forEvaluation ? evaluationModelNotice : generativeModelNotice
const { loadByokModels } = useActions(modelPickerLogic)
switch (byokModelNotice?.kind) {
case 'models-failed': {
const [firstKey] = byokModelNotice.keys
return (
<LemonBanner
type="error"
className="mt-1 text-xs"
action={{ onClick: loadByokModels, children: 'Try again', 'data-attr': 'byok-models-retry' }}
>
{byokModelNotice.keys.length === 1 ? (
<>
Couldn't load models for API key <span className="font-semibold">{firstKey.name}</span> (
{providerLabel(firstKey.provider)}).
</>
) : (
`Couldn't load models for ${byokModelNotice.keys.length} of your API keys.`
)}
</LemonBanner>
)
}
case 'deployments-unlisted': {
const [firstKey] = byokModelNotice.keys
return (
<p className="text-xs text-secondary mt-1">
{byokModelNotice.keys.length === 1 ? (
<>
Azure OpenAI didn't list any deployments for API key{' '}
<span className="font-semibold">{firstKey.name}</span>.
</>
) : (
`Azure OpenAI didn't list any deployments for ${byokModelNotice.keys.length} of your API keys.`
)}{' '}
Type your deployment name in the model search to use it.
</p>
)
}
case 'no-usable-keys':
return (
<p className="text-xs text-secondary mt-1">
No models available because none of your API keys are ready.{' '}
<Link to={PROVIDER_SETTINGS_URL}>Check your API keys</Link>.
</p>
)
default:
return null
}
}