Skip to content

Commit e70242f

Browse files
joshenlimalaister
andauthored
Chore/clean up assistant mcp feature flags (supabase#36772)
* Clean up usage of newOrgAiOptIn and useBedrockAssistant feature flags * Remove all OpenAI endpoints * Fix for self-hosted * Default isLimited to false * Update PG meta tests * Fix unit tests for model * Revert pg meta tests * Fix test --------- Co-authored-by: Alaister Young <[email protected]>
1 parent 9523272 commit e70242f

File tree

25 files changed

+137
-1052
lines changed

25 files changed

+137
-1052
lines changed

apps/studio/components/interfaces/Integrations/CronJobs/CronJobScheduleSection.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useDebounce } from 'use-debounce'
66
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
77
import { useSqlCronGenerateMutation } from 'data/ai/sql-cron-mutation'
88
import { useCronTimezoneQuery } from 'data/database-cron-jobs/database-cron-timezone-query'
9-
import { useFlag } from 'hooks/ui/useFlag'
109
import {
1110
Accordion_Shadcn_,
1211
AccordionContent_Shadcn_,
@@ -36,7 +35,6 @@ interface CronJobScheduleSectionProps {
3635
export const CronJobScheduleSection = ({ form, supportsSeconds }: CronJobScheduleSectionProps) => {
3736
const { project } = useProjectContext()
3837

39-
const useBedrockAssistant = useFlag('useBedrockAssistant')
4038
const [inputValue, setInputValue] = useState('')
4139
const [debouncedValue] = useDebounce(inputValue, 750)
4240
const [useNaturalLanguage, setUseNaturalLanguage] = useState(false)
@@ -67,7 +65,7 @@ export const CronJobScheduleSection = ({ form, supportsSeconds }: CronJobSchedul
6765

6866
useEffect(() => {
6967
if (useNaturalLanguage && debouncedValue) {
70-
generateCronSyntax({ prompt: debouncedValue, useBedrockAssistant })
68+
generateCronSyntax({ prompt: debouncedValue })
7169
}
7270
// eslint-disable-next-line react-hooks/exhaustive-deps
7371
}, [debouncedValue, useNaturalLanguage])

apps/studio/components/interfaces/Organization/GeneralSettings/AIOptInLevelSelector.tsx

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import { ReactNode } from 'react'
22
import { Control } from 'react-hook-form'
33

44
import { AIOptInFormValues } from 'hooks/forms/useAIOptInForm'
5-
import { useFlag } from 'hooks/ui/useFlag'
65
import { FormField_Shadcn_, RadioGroup_Shadcn_, RadioGroupItem_Shadcn_ } from 'ui'
7-
import { Admonition } from 'ui-patterns'
86
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
97
import { OptInToOpenAIToggle } from './OptInToOpenAIToggle'
108

@@ -15,21 +13,6 @@ interface AIOptInLevelSelectorProps {
1513
layout?: 'horizontal' | 'vertical' | 'flex-row-reverse'
1614
}
1715

18-
const AI_OPT_IN_LEVELS_OLD = [
19-
{
20-
value: 'disabled',
21-
title: 'Disabled',
22-
description:
23-
'You do not consent to sharing any database information with Supabase AI and understand that responses will be generic and not tailored to your database',
24-
},
25-
{
26-
value: 'schema',
27-
title: 'Send anonymous metadata',
28-
description:
29-
'You consent to sending anonymous data to Supabase AI, which can improve the answers it shows you.',
30-
},
31-
]
32-
3316
const AI_OPT_IN_LEVELS = [
3417
{
3518
value: 'disabled',
@@ -63,35 +46,19 @@ export const AIOptInLevelSelector = ({
6346
label,
6447
layout = 'vertical',
6548
}: AIOptInLevelSelectorProps) => {
66-
const newOrgAiOptIn = useFlag('newOrgAiOptIn')
67-
const useBedrockAssistant = useFlag('useBedrockAssistant')
68-
69-
const optInLevels = useBedrockAssistant ? AI_OPT_IN_LEVELS : AI_OPT_IN_LEVELS_OLD
70-
7149
return (
7250
<FormItemLayout
7351
label={label}
7452
layout={layout}
7553
description={
7654
<div className="flex flex-col gap-y-4 my-4 max-w-xl">
77-
{useBedrockAssistant && (
78-
<>
79-
{!newOrgAiOptIn && (
80-
<Admonition
81-
type="note"
82-
title="Assistant Opt-in is temporarily disabled"
83-
description="We will re-enable opting in to the assistant shortly!"
84-
/>
85-
)}
86-
<p>
87-
Supabase AI can provide more relevant answers if you choose to share different
88-
levels of data. This feature is powered by Amazon Bedrock which does not store or
89-
log your prompts and completions, nor does it use them to train AWS models or
90-
distribute them to third parties. This is an organization-wide setting, so please
91-
select the level of data you are comfortable sharing.
92-
</p>
93-
</>
94-
)}
55+
<p>
56+
Supabase AI can provide more relevant answers if you choose to share different levels of
57+
data. This feature is powered by Amazon Bedrock which does not store or log your prompts
58+
and completions, nor does it use them to train AWS models or distribute them to third
59+
parties. This is an organization-wide setting, so please select the level of data you
60+
are comfortable sharing.
61+
</p>
9562
<OptInToOpenAIToggle />
9663
</div>
9764
}
@@ -107,7 +74,7 @@ export const AIOptInLevelSelector = ({
10774
disabled={disabled}
10875
className="space-y-2 mb-6"
10976
>
110-
{optInLevels.map((item) => (
77+
{AI_OPT_IN_LEVELS.map((item) => (
11178
<div key={item.value} className="flex items-start space-x-3">
11279
<RadioGroupItem_Shadcn_
11380
value={item.value}

apps/studio/components/interfaces/Organization/GeneralSettings/DataPrivacyForm.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import { useEffect } from 'react'
44
import { FormActions } from 'components/ui/Forms/FormActions'
55
import { useAIOptInForm } from 'hooks/forms/useAIOptInForm'
66
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
7-
import { useFlag } from 'hooks/ui/useFlag'
87
import { Card, CardContent, CardFooter, Form_Shadcn_ } from 'ui'
98
import { AIOptInLevelSelector } from './AIOptInLevelSelector'
109

1110
export const DataPrivacyForm = () => {
12-
const newOrgAiOptIn = useFlag('newOrgAiOptIn')
1311
const { form, onSubmit, isUpdating, currentOptInLevel } = useAIOptInForm()
1412
const canUpdateOrganization = useCheckPermissions(PermissionAction.UPDATE, 'organizations')
1513

@@ -28,7 +26,7 @@ export const DataPrivacyForm = () => {
2826
<CardContent className="pt-6">
2927
<AIOptInLevelSelector
3028
control={form.control}
31-
disabled={!canUpdateOrganization || !newOrgAiOptIn || isUpdating}
29+
disabled={!canUpdateOrganization || isUpdating}
3230
layout="flex-row-reverse"
3331
label="Supabase Assistant Opt-in Level"
3432
/>

apps/studio/components/interfaces/Organization/GeneralSettings/OptInToOpenAIToggle.tsx

Lines changed: 27 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { InlineLink } from 'components/ui/InlineLink'
2-
import { useFlag } from 'hooks/ui/useFlag'
32

43
import {
54
Button,
@@ -12,8 +11,6 @@ import {
1211
} from 'ui'
1312

1413
export const OptInToOpenAIToggle = () => {
15-
const useBedrockAssistant = useFlag('useBedrockAssistant')
16-
1714
return (
1815
<Dialog>
1916
<DialogTrigger asChild>
@@ -29,81 +26,37 @@ export const OptInToOpenAIToggle = () => {
2926
padding="small"
3027
className="flex flex-col gap-y-4 text-sm text-foreground-light"
3128
>
32-
{useBedrockAssistant ? (
33-
<>
34-
<p>
35-
Supabase AI utilizes Amazon Bedrock ("Bedrock"), a service designed with a strong
36-
focus on data privacy and security.
37-
</p>
38-
39-
<p>
40-
Amazon Bedrock does not store or log your prompts and completions. This data is not
41-
used to train any AWS models and is not distributed to third parties or model
42-
providers. Model providers do not have access to Amazon Bedrock logs or customer
43-
prompts and completions.
44-
</p>
45-
46-
<p>
47-
By default, no information is shared with Bedrock unless you explicitly provide
48-
consent. With your permission, Supabase may share customer-generated prompts,
49-
database schema, database data, and project logs with Bedrock. This information is
50-
used solely to generate responses to your queries and is not retained by Bedrock or
51-
used to train their foundation models.
52-
</p>
53-
54-
<p>
55-
If you are a HIPAA Covered Entity, please note that Bedrock is HIPAA eligible, and
56-
Supabase has a Business Associate Agreement in place covering this use.
57-
</p>
58-
59-
<p>
60-
For more detailed information about how we collect and use your data, see our{' '}
61-
<InlineLink href="https://supabase.com/privacy">Privacy Policy</InlineLink>. You can
62-
choose which types of information you consent to share by selecting from the options
63-
in the AI settings.
64-
</p>
65-
</>
66-
) : (
67-
<>
68-
<p>
69-
Supabase AI is a chatbot support tool powered by OpenAI. Supabase will share the
70-
query you submit and information about the databases you manage through Supabase
71-
with OpenAI, L.L.C. and its affiliates in order to provide the Supabase AI tool.
72-
</p>
73-
74-
<p>
75-
OpenAI will only access information about the structure of your databases, such as
76-
table names, column and row headings. OpenAI will not access the contents of the
77-
database itself.
78-
</p>
29+
<p>
30+
Supabase AI utilizes Amazon Bedrock ("Bedrock"), a service designed with a strong focus
31+
on data privacy and security.
32+
</p>
7933

80-
<p>
81-
OpenAI uses this information to generate responses to your query, and does not
82-
retain or use the information to train its algorithms or otherwise improve its
83-
products and services.
84-
</p>
34+
<p>
35+
Amazon Bedrock does not store or log your prompts and completions. This data is not used
36+
to train any AWS models and is not distributed to third parties or model providers.
37+
Model providers do not have access to Amazon Bedrock logs or customer prompts and
38+
completions.
39+
</p>
8540

86-
<p>
87-
If you have your own individual account on Supabase, we will use any personal
88-
information collected through [Supabase AI] to provide you with the [Supabase AI]
89-
tool. If you are in the UK, EEA or Switzerland, the processing of this personal
90-
information is necessary for the performance of a contract between you and us.
91-
</p>
41+
<p>
42+
By default, no information is shared with Bedrock unless you explicitly provide consent.
43+
With your permission, Supabase may share customer-generated prompts, database schema,
44+
database data, and project logs with Bedrock. This information is used solely to
45+
generate responses to your queries and is not retained by Bedrock or used to train their
46+
foundation models.
47+
</p>
9248

93-
<p>
94-
Supabase collects information about the queries you submit through Supabase AI and
95-
the responses you receive to assess the performance of the Supabase AI tool and
96-
improve our services. If you are in the UK, EEA or Switzerland, the processing is
97-
necessary for our legitimate interests, namely informing our product development and
98-
improvement.
99-
</p>
49+
<p>
50+
If you are a HIPAA Covered Entity, please note that Bedrock is HIPAA eligible, and
51+
Supabase has a Business Associate Agreement in place covering this use.
52+
</p>
10053

101-
<p>
102-
For more information about how we use personal information, please see our{' '}
103-
<InlineLink href="https://supabase.com/privacy">privacy policy</InlineLink>.
104-
</p>
105-
</>
106-
)}
54+
<p>
55+
For more detailed information about how we collect and use your data, see our{' '}
56+
<InlineLink href="https://supabase.com/privacy">Privacy Policy</InlineLink>. You can
57+
choose which types of information you consent to share by selecting from the options in
58+
the AI settings.
59+
</p>
10760
</DialogSection>
10861
</DialogContent>
10962
</Dialog>

apps/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { Snippet } from 'data/content/sql-folders-query'
1313
import type { SqlSnippet } from 'data/content/sql-snippets-query'
1414
import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'
1515
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
16-
import { useFlag } from 'hooks/ui/useFlag'
1716
import { useSqlEditorV2StateSnapshot } from 'state/sql-editor-v2'
1817
import { createTabId, useTabsStateSnapshot } from 'state/tabs'
1918
import { AiIconAnimation, Button, Form, Input, Modal } from 'ui'
@@ -34,7 +33,6 @@ const RenameQueryModal = ({
3433
}: RenameQueryModalProps) => {
3534
const { ref } = useParams()
3635
const organization = useSelectedOrganization()
37-
const useBedrockAssistant = useFlag('useBedrockAssistant')
3836

3937
const snapV2 = useSqlEditorV2StateSnapshot()
4038
const tabsSnap = useTabsStateSnapshot()
@@ -66,13 +64,11 @@ const RenameQueryModal = ({
6664

6765
const generateTitle = async () => {
6866
if ('content' in snippet && isSQLSnippet) {
69-
titleSql({ sql: snippet.content.sql, useBedrockAssistant })
67+
titleSql({ sql: snippet.content.sql })
7068
} else {
7169
try {
7270
const { content } = await getContentById({ projectRef: ref, id: snippet.id })
73-
if ('sql' in content) {
74-
titleSql({ sql: content.sql, useBedrockAssistant })
75-
}
71+
if ('sql' in content) titleSql({ sql: content.sql })
7672
} catch (error) {
7773
toast.error('Unable to generate title based on query contents')
7874
}

apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { useOrgAiOptInLevel } from 'hooks/misc/useOrgOptedIntoAi'
2323
import { useSchemasForAi } from 'hooks/misc/useSchemasForAi'
2424
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
2525
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
26-
import { useFlag } from 'hooks/ui/useFlag'
2726
import { BASE_PATH } from 'lib/constants'
2827
import { formatSql } from 'lib/formatSql'
2928
import { detectOS, uuidv4 } from 'lib/helpers'
@@ -81,7 +80,6 @@ export const SQLEditor = () => {
8180
const os = detectOS()
8281
const router = useRouter()
8382
const { ref, id: urlId } = useParams()
84-
const useBedrockAssistant = useFlag('useBedrockAssistant')
8583

8684
const { profile } = useProfile()
8785
const project = useSelectedProject()
@@ -209,15 +207,15 @@ export const SQLEditor = () => {
209207
const setAiTitle = useCallback(
210208
async (id: string, sql: string) => {
211209
try {
212-
const { title: name } = await generateSqlTitle({ sql, useBedrockAssistant })
210+
const { title: name } = await generateSqlTitle({ sql })
213211
snapV2.renameSnippet({ id, name })
214212
const tabId = createTabId('sql', { id })
215213
tabs.updateTab(tabId, { label: name })
216214
} catch (error) {
217215
// [Joshen] No error handler required as this happens in the background and not necessary to ping the user
218216
}
219217
},
220-
[generateSqlTitle, useBedrockAssistant, snapV2]
218+
[generateSqlTitle, snapV2]
221219
)
222220

223221
const prettifyQuery = useCallback(async () => {
@@ -461,9 +459,7 @@ export const SQLEditor = () => {
461459
completion,
462460
isLoading: isCompletionLoading,
463461
} = useCompletion({
464-
api: useBedrockAssistant
465-
? `${BASE_PATH}/api/ai/sql/complete-v2`
466-
: `${BASE_PATH}/api/ai/sql/complete`,
462+
api: `${BASE_PATH}/api/ai/sql/complete-v2`,
467463
body: {
468464
projectRef: project?.ref,
469465
connectionString: project?.connectionString,

0 commit comments

Comments
 (0)