Files
supabase/apps/studio/hooks/misc/useSchemasForAi.ts
T
Ivan VasilovandJoshen Lim 6a29cd2bec feat: Choose which schemas to share with OpenAI (#28594)
* Change the getEntityDefinitions query to accept list of schemas instead of being hardcoded to public schema.

* Add a schema combo box for selecting schemas.

* Use the combobox in the SQL editor to select which schemas should be sent to the AI when asking a question.

* Add configurable schemas to AiPolicyEditor.

* Remove unneeded hook.

* Fix the AI settings modal.

* Add keys to the entity definitions query.

* Fix the AI settings modal which is used by cmdk flow.

* Minor fixes.

* Address feedback

* Some fixes

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-08-15 14:38:19 +08:00

20 lines
553 B
TypeScript

import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { LOCAL_STORAGE_KEYS } from 'lib/constants'
import { Dispatch, SetStateAction } from 'react'
/**
* Returns which schemas are ok to be sent to AI.
*/
export function useSchemasForAi(
ref: string
): readonly [string[], Dispatch<SetStateAction<string[]>>] {
const [enabledSchemas, setEnabledSchemas] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.SQL_EDITOR_AI_SCHEMA(ref),
['public']
)
if (!ref) return [[], () => {}]
return [enabledSchemas, setEnabledSchemas]
}