1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| import { createStore } from 'zustand'
| import type { Features } from './types'
| import { Resolution, TransferMethod } from '@/types/app'
|
| export type FeaturesModal = {
| showFeaturesModal: boolean
| setShowFeaturesModal: (showFeaturesModal: boolean) => void
| }
|
| export type FeaturesState = {
| features: Features
| }
|
| export type FeaturesAction = {
| setFeatures: (features: Features) => void
| }
|
| export type FeatureStoreState = FeaturesState & FeaturesAction & FeaturesModal
|
| export type FeaturesStore = ReturnType<typeof createFeaturesStore>
|
| export const createFeaturesStore = (initProps?: Partial<FeaturesState>) => {
| const DEFAULT_PROPS: FeaturesState = {
| features: {
| moreLikeThis: {
| enabled: false,
| },
| opening: {
| enabled: false,
| },
| suggested: {
| enabled: false,
| },
| text2speech: {
| enabled: false,
| },
| speech2text: {
| enabled: false,
| },
| citation: {
| enabled: false,
| },
| moderation: {
| enabled: false,
| },
| file: {
| image: {
| enabled: false,
| detail: Resolution.high,
| number_limits: 3,
| transfer_methods: [TransferMethod.local_file, TransferMethod.remote_url],
| },
| },
| annotationReply: {
| enabled: false,
| },
| },
| }
| return createStore<FeatureStoreState>()(set => ({
| ...DEFAULT_PROPS,
| ...initProps,
| setFeatures: features => set(() => ({ features })),
| showFeaturesModal: false,
| setShowFeaturesModal: showFeaturesModal => set(() => ({ showFeaturesModal })),
| }))
| }
|
|