AIOptInLevelSelector.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import { ReactNode } from 'react'
  2. import { Control } from 'react-hook-form'
  3. import { FormField, RadioGroup, RadioGroupItem } from 'ui'
  4. import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
  5. import { OptInToOpenAIToggle } from './OptInToOpenAIToggle'
  6. import { AIOptInFormValues } from '@/hooks/forms/useAIOptInForm'
  7. import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
  8. interface AIOptInLevelSelectorProps {
  9. control: Control<AIOptInFormValues>
  10. disabled?: boolean
  11. label?: ReactNode
  12. layout?: 'horizontal' | 'vertical' | 'flex-row-reverse'
  13. }
  14. export const AIOptInLevelSelector = ({
  15. control,
  16. disabled,
  17. label,
  18. layout = 'vertical',
  19. }: AIOptInLevelSelectorProps) => {
  20. const {
  21. aiOptInLevelDisabled,
  22. aiOptInLevelSchema,
  23. aiOptInLevelSchemaAndLog,
  24. aiOptInLevelSchemaAndLogAndData,
  25. } = useIsFeatureEnabled([
  26. 'ai:opt_in_level_disabled',
  27. 'ai:opt_in_level_schema',
  28. 'ai:opt_in_level_schema_and_log',
  29. 'ai:opt_in_level_schema_and_log_and_data',
  30. ])
  31. const AI_OPT_IN_LEVELS = [
  32. ...(aiOptInLevelDisabled
  33. ? [
  34. {
  35. value: 'disabled',
  36. title: 'Disabled',
  37. description:
  38. 'You do not consent to sharing any database information with third-party AI providers and understand that responses will be generic and not tailored to your database',
  39. },
  40. ]
  41. : []),
  42. ...(aiOptInLevelSchema
  43. ? [
  44. {
  45. value: 'schema',
  46. title: 'Schema Only',
  47. description:
  48. 'You consent to sharing your database’s schema metadata (such as table and column names, data types, and relationships—but not actual database data) with third-party AI providers',
  49. },
  50. ]
  51. : []),
  52. ...(aiOptInLevelSchemaAndLog
  53. ? [
  54. {
  55. value: 'schema_and_log',
  56. title: 'Schema & Logs',
  57. description:
  58. 'You consent to sharing your schema and logs (which may contain PII/database data) with third-party AI providers for better results',
  59. },
  60. ]
  61. : []),
  62. ...(aiOptInLevelSchemaAndLogAndData
  63. ? [
  64. {
  65. value: 'schema_and_log_and_data',
  66. title: 'Schema, Logs & Database Data',
  67. description:
  68. 'You consent to give third-party AI providers full access to run database read-only queries and analyze results for optimal results',
  69. },
  70. ]
  71. : []),
  72. ]
  73. return (
  74. <FormItemLayout
  75. label={label}
  76. layout={layout}
  77. description={
  78. <div className="flex flex-col gap-y-4 my-4 max-w-xl">
  79. <p>
  80. Briven AI can provide more relevant answers if you choose to share different levels of
  81. data. This feature is powered by third-party AI providers. This is an organization-wide
  82. setting, so please select the level of data you are comfortable sharing.
  83. </p>
  84. <p>
  85. For organizations with HIPAA compliance enabled in their Briven configuration, any
  86. consented information will only be shared with third-party AI providers with whom
  87. Briven has established a Business Associate Agreement (BAA).
  88. </p>
  89. <OptInToOpenAIToggle />
  90. </div>
  91. }
  92. >
  93. <div className="max-w-xl">
  94. <FormField
  95. control={control}
  96. name="aiOptInLevel"
  97. render={({ field }) => (
  98. <RadioGroup
  99. value={field.value}
  100. onValueChange={field.onChange}
  101. disabled={disabled}
  102. className="space-y-2 mb-6"
  103. >
  104. {AI_OPT_IN_LEVELS.map((item) => (
  105. <div key={item.value} className="flex items-start space-x-3">
  106. <RadioGroupItem
  107. value={item.value}
  108. id={`ai-opt-in-${item.value}`}
  109. className="mt-0.5"
  110. />
  111. <label
  112. htmlFor={`ai-opt-in-${item.value}`}
  113. className="cursor-pointer flex flex-col"
  114. >
  115. <span className="text-sm font-medium text-foreground">{item.title}</span>
  116. <span className="text-sm text-foreground-light">{item.description}</span>
  117. </label>
  118. </div>
  119. ))}
  120. </RadioGroup>
  121. )}
  122. />
  123. </div>
  124. </FormItemLayout>
  125. )
  126. }