Skip to content

Commit 7505c29

Browse files
authored
Update AI model check (supabase#37395)
* Update AI model chekc * Add comment * Fix test
1 parent 5f76c85 commit 7505c29

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

apps/studio/lib/ai/model.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('getModel', () => {
1818

1919
beforeEach(() => {
2020
vi.resetAllMocks()
21-
vi.stubEnv('AWS_BEDROCK_PROFILE', 'test')
21+
vi.stubEnv('AWS_BEDROCK_ROLE_ARN', 'test')
2222
})
2323

2424
afterEach(() => {

apps/studio/lib/ai/model.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export const ModelErrorMessage =
3333
export async function getModel(routingKey?: string, isLimited?: boolean): Promise<ModelResponse> {
3434
const hasAwsCredentials = await checkAwsCredentials()
3535

36-
const hasAwsBedrockprofile = !!process.env.AWS_BEDROCK_PROFILE
36+
const hasAwsBedrockRoleArn = !!process.env.AWS_BEDROCK_ROLE_ARN
3737
const hasOpenAIKey = !!process.env.OPENAI_API_KEY
3838

39-
if (hasAwsBedrockprofile && hasAwsCredentials) {
39+
if (hasAwsBedrockRoleArn && hasAwsCredentials) {
4040
const bedrockModel = IS_THROTTLED || isLimited ? BEDROCK_NORMAL_MODEL : BEDROCK_PRO_MODEL
4141
const bedrock = createRoutedBedrock(routingKey)
4242

@@ -45,6 +45,7 @@ export async function getModel(routingKey?: string, isLimited?: boolean): Promis
4545
}
4646
}
4747

48+
// [Joshen] Only for local/self-hosted, hosted should always only use bedrock
4849
if (hasOpenAIKey) {
4950
return {
5051
model: openai(OPENAI_MODEL),

0 commit comments

Comments
 (0)