mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
* step 1 * use mcp * system prompt * clean up * space * clean up * add three state opt in toggle * clean up * todo * hooks * refactor opt in form and modal * refinements * add bedrock * remove console * update mcp util * use bedrock * remove openai sdk package * re-add tools * update complete endpoints * fix: ai assistant markdown formatting (#35541) * fix: mcp types and project ref (#35540) * feat: more flexible aws credential provider (#35538) * feat: more flexible aws credential provider * fix: add AWS_REGION to turbo env vars * change to allowed * update complete endpoints * add an additional permission * refinements * use claud 4 * legal copy changes * update other ai functions to use bedrock * update generate v3 copy * remove generate sql modal * fixes for query block * re-add dragging to reports * clean up * add open ai edge function example * use handle error from fetchers * remove schema and lean on tools * copy * Assistant MCP tests (#36049) * feat: refactor and test mcp and model logic * fix: remove get_project tool * fix: remove additional get_project tool references * update copy * Clean up, fixes, refactors * oops * Float errors from AI endpoionts as toasts * Use a env var AWS_BEDROCK_PROFILE for bedrock. * Rename the env var for AWS bedrock profile. * feat: support custom aws bedrock env vars * chore: add comments explaining aws credential chain * MCP Self Hosted Check (#36185) support self hosted * feat: bedrock auth via vercel oidc * Fix broken unit test * Feeeex * Refactor useOrgOptedIntoAi * Remove useDisallowHipaa hook * small system prompt change * readd vercel packages * fix self hosted * increase max duration * try more direct prompt * max duration 90 * reduce max steps and add loading * mono font * backwards compat styling * Chore/limit number of messages sent to assistant (#36388) * Limit number of historical messages that get sent to assistant * Update max chat history to 5 * alignment * bump mcp server version * Add feature flag for opt in tags (#36466) * Add feature flag for opt in tags * Add one more check * security section system prompt * rely on default link and replace image markdown * Add custom link component to assistant message block (#36527) * Add custom link component to assistant message block * Update based on feedback * Render plain text if URL is deemed unsafe * fix mcp tools and parse data (#36593) * Update Admonition for AI Assistant for when opt in is re-enabled (#36663) * Update Admonition for AI Assistant for when opt in is re-enabled * Update * Smol fix * Fix TS * Tiny --------- Co-authored-by: Greg Richardson <greg.nmr@gmail.com> Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import { openai } from '@ai-sdk/openai'
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import * as bedrockModule from './bedrock'
|
|
import { bedrock } from './bedrock'
|
|
import { getModel, ModelErrorMessage, modelsByProvider } from './model'
|
|
|
|
vi.mock('@ai-sdk/openai', () => ({
|
|
openai: vi.fn(() => 'openai-model'),
|
|
}))
|
|
|
|
vi.mock('./bedrock', () => ({
|
|
bedrock: vi.fn(() => 'bedrock-model'),
|
|
checkAwsCredentials: vi.fn(),
|
|
}))
|
|
|
|
describe('getModel', () => {
|
|
const originalEnv = { ...process.env }
|
|
|
|
beforeEach(() => {
|
|
vi.resetAllMocks()
|
|
})
|
|
|
|
afterEach(() => {
|
|
process.env = { ...originalEnv }
|
|
})
|
|
|
|
it('should return bedrock model when AWS credentials are available and AWS_BEDROCK_REGION is set', async () => {
|
|
vi.mocked(bedrockModule.checkAwsCredentials).mockResolvedValue(true)
|
|
process.env.AWS_BEDROCK_REGION = 'us-east-1'
|
|
|
|
const { model, error } = await getModel()
|
|
|
|
expect(model).toEqual('bedrock-model')
|
|
expect(bedrock).toHaveBeenCalledWith(modelsByProvider.bedrock)
|
|
expect(error).toBeUndefined()
|
|
})
|
|
|
|
it('should return error when AWS credentials are available but AWS_BEDROCK_REGION is not set', async () => {
|
|
vi.mocked(bedrockModule.checkAwsCredentials).mockResolvedValue(true)
|
|
delete process.env.AWS_BEDROCK_REGION
|
|
|
|
const { error } = await getModel()
|
|
|
|
expect(error).toEqual(new Error('AWS_BEDROCK_REGION is not set'))
|
|
})
|
|
|
|
it('should return OpenAI model when AWS credentials are not available but OPENAI_API_KEY is set', async () => {
|
|
vi.mocked(bedrockModule.checkAwsCredentials).mockResolvedValue(false)
|
|
process.env.OPENAI_API_KEY = 'test-key'
|
|
|
|
const { model } = await getModel()
|
|
|
|
expect(model).toEqual('openai-model')
|
|
expect(openai).toHaveBeenCalledWith(modelsByProvider.openai)
|
|
})
|
|
|
|
it('should return error when neither AWS credentials nor OPENAI_API_KEY is available', async () => {
|
|
vi.mocked(bedrockModule.checkAwsCredentials).mockResolvedValue(false)
|
|
delete process.env.OPENAI_API_KEY
|
|
|
|
const { error } = await getModel()
|
|
|
|
expect(error).toEqual(new Error(ModelErrorMessage))
|
|
})
|
|
})
|