1
-
2
-
3
- import { Stack } from '@mui/material' ;
4
- import { Psychology , ChatBubble , Insights } from '@mui/icons-material' ;
1
+ import React from 'react' ;
2
+ import { Stack , Typography , Box , Switch , styled } from '@mui/material' ;
5
3
import { useDeploymentStore } from '../state/Deployment' ;
6
-
7
4
import {
8
5
useOptionsStore , CONFIGURE_PROMPTS , CONFIGURE_AGENTS ,
9
6
CONFIGURE_WORKBENCH ,
10
7
} from '../state/Options' ;
11
8
12
- import Option from './Option' ;
9
+ interface OptionProps extends React . PropsWithChildren {
10
+ enabled : boolean ;
11
+ onChange : ( event : React . ChangeEvent < HTMLInputElement > ) => void ;
12
+ title : string ;
13
+ }
14
+
15
+ const StyledOption = styled ( Box , {
16
+ shouldForwardProp : ( prop ) => prop !== 'selected' ,
17
+ } ) < { selected : boolean } > ( ( { theme, selected } ) => ( {
18
+ display : 'flex' ,
19
+ flexDirection : 'column' ,
20
+ padding : theme . spacing ( 2 ) ,
21
+ borderRadius : theme . shape . borderRadius ,
22
+ backgroundColor : selected ? theme . palette . primary . main : theme . palette . background . paper ,
23
+ color : selected ? theme . palette . primary . contrastText : theme . palette . text . primary ,
24
+ border : `1px solid ${ theme . palette . divider } ` ,
25
+ minWidth : '200px' ,
26
+ maxWidth : '350px' ,
27
+ flex : '1 1 auto' ,
28
+ transition : 'background-color 0.3s ease, color 0.3s ease' ,
29
+ [ theme . breakpoints . down ( 'sm' ) ] : {
30
+ minWidth : '90%' ,
31
+ maxWidth : '100%' ,
32
+ }
33
+ } ) ) ;
34
+
35
+ const StyledOptionTitle = styled ( Typography ) ( ( { theme } ) => ( {
36
+ fontWeight : 600 ,
37
+ marginBottom : theme . spacing ( 1 ) ,
38
+ display : 'flex' ,
39
+ alignItems : 'center' ,
40
+ justifyContent : 'space-between' ,
41
+ } ) ) ;
42
+
43
+ const StyledOptionDescription = styled ( Typography ) ( ( ) => ( { // Fixed: Removed theme parameter since not used
44
+ whiteSpace : 'normal' ,
45
+ wordBreak : 'break-word' ,
46
+ } ) ) ;
47
+
48
+
49
+ const StyledSwitch = styled ( Switch ) ( ( { theme } ) => ( {
50
+ '& .MuiSwitch-switchBase.Mui-checked' : {
51
+ color : theme . palette . secondary . main ,
52
+ '&:hover' : {
53
+ backgroundColor : theme . palette . secondary . main + '08' ,
54
+ } ,
55
+ } ,
56
+ '& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track' : {
57
+ backgroundColor : theme . palette . secondary . main ,
58
+ } ,
59
+ '& .MuiSwitch-thumb' : {
60
+ backgroundColor : theme . palette . common . white ,
61
+ } ,
62
+ '& .MuiSwitch-track' : {
63
+ backgroundColor : theme . palette . grey [ 500 ] ,
64
+ }
65
+ } ) ) ;
13
66
14
- const ParamsForm : React . FC = ( {
15
- } ) => {
16
67
17
- const options = useOptionsStore ( ( state ) => state . options ) ;
68
+ const Option : React . FC < OptionProps > = ( { enabled, onChange, title, children } ) => {
69
+ return (
70
+ < StyledOption selected = { enabled } >
71
+ < StyledOptionTitle variant = "h6" >
72
+ < Typography variant = "h6" component = "h3" >
73
+ { title }
74
+ </ Typography >
75
+ < StyledSwitch checked = { enabled } onChange = { onChange } inputProps = { { 'aria-label' : 'controlled' } } />
76
+ </ StyledOptionTitle >
77
+ < StyledOptionDescription variant = "body2" >
78
+ { children }
79
+ </ StyledOptionDescription >
80
+
81
+ </ StyledOption >
82
+ ) ;
83
+ } ;
18
84
19
- const setOptions = useOptionsStore ( ( state ) => state . setOptions ) ;
20
85
21
- const setConfigUrl =
22
- useDeploymentStore ( ( state ) => state . setConfigUrl ) ;
86
+ const ParamsForm : React . FC = ( ) => {
87
+ const options = useOptionsStore ( ( state ) => state . options ) ;
88
+ const setOptions = useOptionsStore ( ( state ) => state . setOptions ) ;
89
+ const setConfigUrl = useDeploymentStore ( ( state ) => state . setConfigUrl ) ;
23
90
24
91
useOptionsStore . subscribe ( ( ) => {
25
92
setConfigUrl ( "" ) ;
@@ -29,7 +96,7 @@ const ParamsForm: React.FC = ({
29
96
const configureAgents = options . has ( CONFIGURE_AGENTS ) ;
30
97
const configureWorkbench = options . has ( CONFIGURE_WORKBENCH ) ;
31
98
32
- const set = ( o : string , value : boolean ) => {
99
+ const set = ( o : string , value : boolean ) => {
33
100
if ( value ) {
34
101
const opts = new Set ( options ) ;
35
102
opts . add ( o ) ;
@@ -41,29 +108,29 @@ const ParamsForm: React.FC = ({
41
108
}
42
109
}
43
110
44
- const onConfigurePrompts = ( ) => {
45
- set ( CONFIGURE_PROMPTS , ! configurePrompts ) ;
111
+ const onConfigurePrompts = ( event : React . ChangeEvent < HTMLInputElement > ) => {
112
+ set ( CONFIGURE_PROMPTS , event . target . checked ) ;
46
113
} ;
47
114
48
- const onConfigureAgents = ( ) => {
49
- set ( CONFIGURE_AGENTS , ! configureAgents ) ;
115
+ const onConfigureAgents = ( event : React . ChangeEvent < HTMLInputElement > ) => {
116
+ set ( CONFIGURE_AGENTS , event . target . checked ) ;
50
117
} ;
51
118
52
- const onConfigureWorkbench = ( ) => {
53
- set ( CONFIGURE_WORKBENCH , ! configureWorkbench ) ;
119
+ const onConfigureWorkbench = ( event : React . ChangeEvent < HTMLInputElement > ) => {
120
+ set ( CONFIGURE_WORKBENCH , event . target . checked ) ;
54
121
} ;
55
122
56
123
return (
57
124
< >
58
-
59
- < Stack direction = "row" spacing = { 2 }
60
- sx = { { flexWrap : 'wrap' } } useFlexGap
125
+ < Stack
126
+ direction = "row"
127
+ spacing = { 2 }
128
+ sx = { { flexWrap : 'wrap' , width : '100%' } }
129
+ useFlexGap
61
130
>
62
-
63
131
< Option
64
132
enabled = { configurePrompts }
65
133
onChange = { onConfigurePrompts }
66
- avatar = { < ChatBubble color = "primary" /> }
67
134
title = "Data Extraction Prompts"
68
135
>
69
136
Tailor the LLM system prompts, data extraction prompts,
@@ -73,8 +140,7 @@ const ParamsForm: React.FC = ({
73
140
< Option
74
141
enabled = { configureAgents }
75
142
onChange = { onConfigureAgents }
76
- avatar = { < Psychology color = "primary" /> }
77
- title = "Agent Definitions"
143
+ title = "Agent Tools"
78
144
>
79
145
Add Agents that use a ReAct approach. Customize the
80
146
Agent definitions, options, and arguments.
@@ -83,19 +149,14 @@ const ParamsForm: React.FC = ({
83
149
< Option
84
150
enabled = { configureWorkbench }
85
151
onChange = { onConfigureWorkbench }
86
- avatar = { < Insights color = "primary" /> }
87
- title = "Workbench UI"
152
+ title = "Data Workbench"
88
153
>
89
- An experimental UI providing some tools to interact with
90
- data. Once launched, accessible on port 8888.
154
+ An experimental UI providing tools to explore extracted
155
+ data. Once launched, accessible on port 8888.
91
156
</ Option >
92
-
93
157
</ Stack >
94
-
95
158
</ >
96
-
97
159
) ;
98
160
} ;
99
161
100
- export default ParamsForm ;
101
-
162
+ export default ParamsForm ;
0 commit comments