@@ -40,7 +40,13 @@ const ToolsTab = ({
40
40
} ) => {
41
41
const [ params , setParams ] = useState < Record < string , unknown > > ( { } ) ;
42
42
useEffect ( ( ) => {
43
- setParams ( { } ) ;
43
+ const params = Object . entries (
44
+ selectedTool ?. inputSchema . properties ?? [ ] ,
45
+ ) . map ( ( [ key , value ] ) => [
46
+ key ,
47
+ generateDefaultValue ( value as JsonSchemaType ) ,
48
+ ] ) ;
49
+ setParams ( Object . fromEntries ( params ) ) ;
44
50
} , [ selectedTool ] ) ;
45
51
46
52
const renderToolResult = ( ) => {
@@ -194,10 +200,7 @@ const ToolsTab = ({
194
200
description : prop . description ,
195
201
items : prop . items ,
196
202
} }
197
- value = {
198
- ( params [ key ] as JsonValue ) ??
199
- generateDefaultValue ( prop )
200
- }
203
+ value = { params [ key ] as JsonValue }
201
204
onChange = { ( newValue : JsonValue ) => {
202
205
setParams ( {
203
206
...params ,
@@ -206,29 +209,40 @@ const ToolsTab = ({
206
209
} }
207
210
/>
208
211
</ div >
209
- ) : (
212
+ ) : prop . type === "number" || prop . type === "integer" ? (
210
213
< Input
211
- type = {
212
- prop . type === "number" || prop . type === "integer"
213
- ? "number"
214
- : "text"
215
- }
214
+ type = "number"
216
215
id = { key }
217
216
name = { key }
218
217
placeholder = { prop . description }
219
218
value = { ( params [ key ] as string ) ?? "" }
220
219
onChange = { ( e ) =>
221
220
setParams ( {
222
221
...params ,
223
- [ key ] :
224
- prop . type === "number" ||
225
- prop . type === "integer"
226
- ? Number ( e . target . value )
227
- : e . target . value ,
222
+ [ key ] : Number ( e . target . value ) ,
228
223
} )
229
224
}
230
225
className = "mt-1"
231
226
/>
227
+ ) : (
228
+ < div className = "mt-1" >
229
+ < DynamicJsonForm
230
+ onlyJSON
231
+ schema = { {
232
+ type : prop . type ,
233
+ properties : prop . properties ,
234
+ description : prop . description ,
235
+ items : prop . items ,
236
+ } }
237
+ value = { params [ key ] as JsonValue }
238
+ onChange = { ( newValue : JsonValue ) => {
239
+ setParams ( {
240
+ ...params ,
241
+ [ key ] : newValue ,
242
+ } ) ;
243
+ } }
244
+ />
245
+ </ div >
232
246
) }
233
247
</ div >
234
248
) ;
0 commit comments