Files
supabase/apps/studio/lib/ai/model.utils.ts
T
1973615a42 Prompt GPT-5 Optimizations (#39031)
* update onboarding

* update model and fix part issue

* action orientated assistant

* fix tool

* lock

* remove unused filter

* fix tests

* fix again

* update package

* update container

* fix tests

* refactor(ai assistant): break out message markdown and profile picture

* wip

* refactor(ai assistant): break up message component

* refactor: break ai assistant message down into multiple files

* add limitations prompt

* limitations prompt

* link prompt

* refactor: simplify ReportBlock state

* fix: styling of draggable report block header

When the drag handle is showing, it overlaps with the block header.
Decrease the opacity of the header so the handle can be seen and the two
can be distinguished.

* fix: minor tweaks to tool ui

* refactor: simplify DisplayBlockRenderer state

* fix: remove double deploy button in edge function block

When the confirm footer is shown, the deploy button on the top right should be
hidden (not just disabled) to avoid confusion.

* refactor, test: message sanitization by opt-in level

Refactor the message sanitization to have more type safety and be more testable.
Add tests to ensure:

- Message sanitization always runs on generate-v4
- Message sanitization correctly works by opt-in level

* Fix conflicts in pnpm lock

* Couple of nits and refactors

* Revert casing for report block snippet

* adjust sanitised prompt

* Fix tests

* prompt optimizer

* remove realtime for now

* Update apps/studio/lib/ai/prompts.ts

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/studio/lib/ai/prompts.ts

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

---------

Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-09-29 14:07:53 +10:00

75 lines
2.1 KiB
TypeScript

export type ProviderName = 'bedrock' | 'openai' | 'anthropic'
export type BedrockModel = 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'openai.gpt-oss-120b-1:0'
export type OpenAIModel = 'gpt-5' | 'gpt-5-mini'
export type AnthropicModel = 'claude-sonnet-4-20250514' | 'claude-3-5-haiku-20241022'
export type Model = BedrockModel | OpenAIModel | AnthropicModel
export type ProviderModelConfig = {
/** Optional providerOptions to attach to the system message for this model */
promptProviderOptions?: Record<string, any>
/** The default model for this provider (used when limited or no preferred specified) */
default: boolean
}
export type ProviderRegistry = {
bedrock: {
models: Record<BedrockModel, ProviderModelConfig>
providerOptions?: Record<string, any>
}
openai: {
models: Record<OpenAIModel, ProviderModelConfig>
providerOptions?: Record<string, any>
}
anthropic: {
models: Record<AnthropicModel, ProviderModelConfig>
providerOptions?: Record<string, any>
}
}
export const PROVIDERS: ProviderRegistry = {
bedrock: {
models: {
'anthropic.claude-3-7-sonnet-20250219-v1:0': {
promptProviderOptions: {
bedrock: {
// Always cache the system prompt (must not contain dynamic content)
cachePoint: { type: 'default' },
},
},
default: false,
},
'openai.gpt-oss-120b-1:0': {
default: true,
},
},
},
openai: {
models: {
'gpt-5': { default: false },
'gpt-5-mini': { default: true },
},
providerOptions: {
openai: {
reasoningEffort: 'minimal',
},
},
},
anthropic: {
models: {
'claude-sonnet-4-20250514': { default: false },
'claude-3-5-haiku-20241022': { default: true },
},
},
}
export function getDefaultModelForProvider(provider: ProviderName): Model | undefined {
const models = PROVIDERS[provider]?.models as Record<Model, ProviderModelConfig>
if (!models) return undefined
return Object.keys(models).find((id) => models[id as Model]?.default) as Model | undefined
}